/* ==========================================================================
   FAMILY DASH — pixel/arcade dark theme (compact build)
   No framework, no build step. Everything is hand-rolled pixel UI.
   Sizes are tuned for a phone: touch targets stay >= 44px, everything else
   is trimmed so a full week of data fits above the fold.
   ========================================================================== */

/* ---------- self-hosted pixel fonts (Google Fonts, subset by Google, served locally) ---------- */

@font-face {
  font-family: 'PixelBody';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/pixelbody-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PixelBody';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/pixelbody-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'PixelBody';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/pixelbody-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'PixelHead';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/pixelhead-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'PixelHead';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/pixelhead-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'PixelHead';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/pixelhead-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'PixelHead';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/pixelhead-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #080a12;
  --bg-2: #0f1322;
  --panel: #141a2e;
  --panel-2: #1b2340;
  --line: #2b3560;
  --line-soft: #1e2745;
  --text: #e8edff;
  --text-dim: #98a3cc;
  --accent: #3ad1ff;
  --pink: #ff4d8d;
  --lime: #8cff3a;
  --yellow: #ffd23a;
  --violet: #b96bff;
  --danger: #ff5c5c;
  --ok: #4dff9e;
  --shadow: 3px 3px 0 0 #050713;
  --display: 'PixelHead', 'Courier New', monospace;
  --body: 'PixelBody', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.28;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(circle at 12% -10%, rgba(58, 209, 255, .16), transparent 45%),
    radial-gradient(circle at 88% 4%, rgba(255, 77, 141, .14), transparent 42%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 45%);
  background-attachment: fixed;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

/* subtle CRT scanlines — pure flavour, disabled for reduced motion */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: .2;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .045) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

img, canvas, .pixel { image-rendering: pixelated; image-rendering: -moz-crisp-edges; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, .head {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  margin: 0 0 8px;
}

h1 { font-size: 13px; }
h2 { font-size: 11px; }
h3 { font-size: 9px; }

.dim { color: var(--text-dim); }
.mono { font-family: var(--display); }
.center { text-align: center; }
.mt { margin-top: 10px; }
.mb { margin-bottom: 10px; }
.nowrap { white-space: nowrap; }
.small { font-size: 15px; }

/* ---------- layout ---------- */

.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 9px 4px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  background: rgba(8, 10, 18, .92);
  backdrop-filter: blur(6px);
  border-bottom: 3px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--display);
  font-size: 9px;
  color: var(--text);
  letter-spacing: 1px;
}

.brand .dot {
  width: 10px;
  height: 10px;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  animation: blink 1.6s steps(1, end) infinite;
}

.spacer { flex: 1; }

.userchip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 2px;
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 16px;
}

.userchip:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- cards & panels ---------- */

.card {
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  padding: 9px;
  margin-bottom: 9px;
  animation: rise .24s ease-out both;
}

.card.accent { border-color: var(--accent); }
.card.flat { box-shadow: none; }

.card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--display);
  font-size: 8px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.card-title::after {
  content: '';
  flex: 1;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px);
}

/* ---------- avatars ---------- */

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 3px solid var(--line);
  font-family: var(--display);
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  flex: 0 0 auto;
}

.avatar img { width: 100%; height: 100%; display: block; }
.avatar.lg { width: 52px; height: 52px; font-size: 16px; }
.avatar.xl { width: 72px; height: 72px; font-size: 22px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 44px;
  background: var(--panel-2);
  color: var(--text);
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  font-family: var(--display);
  font-size: 9px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .06s steps(2, end), box-shadow .06s steps(2, end), border-color .12s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 0 #050713; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: #04121b; border-color: #9fe9ff; }
.btn.pink { background: var(--pink); color: #20030d; border-color: #ff9dc0; }
.btn.lime { background: var(--lime); color: #0c2000; border-color: #d3ff9d; }
.btn.ghost { background: transparent; }
.btn.danger { background: #2a0d12; border-color: var(--danger); color: #ffd3d3; }
.btn.sm { min-height: 34px; padding: 5px 9px; font-size: 7px; }
.btn.tall { min-height: 50px; font-size: 11px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; gap: 7px; flex-wrap: wrap; }
.btn-row > * { flex: 1; }

/* ---------- forms ---------- */

label { display: block; font-size: 15px; color: var(--text-dim); margin-bottom: 4px; }

input[type=text], input[type=password], input[type=file], select, textarea {
  width: 100%;
  padding: 8px 10px;
  min-height: 42px;
  background: #0b0f1d;
  color: var(--text);
  border: 3px solid var(--line);
  font-family: var(--body);
  font-size: 18px;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(58, 209, 255, .18); }
input::placeholder { color: #55618f; }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--text); }
.checkline input { width: 20px; height: 20px; accent-color: var(--accent); }

.field { margin-bottom: 9px; }
.hint { font-size: 14px; color: var(--text-dim); }

.alert {
  border: 3px solid var(--line);
  padding: 7px 9px;
  margin-bottom: 9px;
  font-size: 16px;
  animation: rise .22s ease-out both;
}

.alert.ok { border-color: var(--ok); background: rgba(77, 255, 158, .08); color: #c8ffe6; }
.alert.err { border-color: var(--danger); background: rgba(255, 92, 92, .08); color: #ffd6d6; }

/* ---------- tracker tabs ---------- */

.tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 2px 7px;
  margin: 0 -2px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 5px;
  min-height: 46px;
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: var(--display);
  font-size: 9px;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: transform .12s, border-color .12s, background .12s;
}

.tab:hover { text-decoration: none; border-color: var(--text-dim); }
.tab.active {
  background: var(--panel-2);
  border-color: var(--tab-color, var(--accent));
  box-shadow: 3px 3px 0 0 #050713, 0 0 0 3px rgba(58, 209, 255, .12);
  transform: translateY(-2px);
}
.tab.active .avatar { border-color: var(--tab-color, var(--accent)); box-shadow: 0 0 12px -2px var(--tab-color, var(--accent)); }

/* ---------- big weight dial ---------- */

.dial { text-align: center; }

.dial-date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 5px;
  font-family: var(--display);
  font-size: 8px;
  color: var(--text-dim);
}

.dial-date a {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 11px;
}

.weight-display {
  width: 100%;
  border: 4px solid var(--accent);
  background: #05070f;
  padding: 10px 8px;
  text-align: center;
  position: relative;
  box-shadow: inset 0 0 28px rgba(58, 209, 255, .12), var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}

.weight-display.saved { animation: pop .5s steps(6, end); }

.weight-input {
  width: 100%;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-family: var(--display) !important;
  font-size: 36px !important;
  line-height: 1.15;
  text-align: center;
  color: var(--accent);
  padding: 0 !important;
  min-height: 0 !important;
  text-shadow: 0 0 16px rgba(58, 209, 255, .55);
  caret-color: var(--accent);
}

.weight-unit { font-family: var(--display); font-size: 9px; color: var(--text-dim); margin-top: 3px; }

.delta {
  font-family: var(--display);
  font-size: 8px;
  margin-top: 5px;
}
.delta.up { color: var(--yellow); }
.delta.down { color: var(--lime); }
.delta.same { color: var(--text-dim); }

/* ---------- keypad ---------- */

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 9px;
}

.key {
  min-height: 52px;
  background: var(--panel-2);
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: var(--display);
  font-size: 18px;
  cursor: pointer;
  transition: transform .05s steps(2, end), box-shadow .05s steps(2, end), border-color .1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.key:hover { border-color: var(--accent); }
.key:active { transform: translate(3px, 3px); box-shadow: 0 0 0 0 #050713; }
.key.zero { grid-column: span 1; }
.key.action { font-size: 14px; }

#save-weight { margin-top: 9px; }

/* ---------- measurement list ---------- */

.rows { display: flex; flex-direction: column; gap: 6px; }

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  background: var(--panel-2);
  border: 3px solid var(--line-soft);
}

.row .when { font-family: var(--display); font-size: 8px; color: var(--text-dim); }
.row .val { font-family: var(--display); font-size: 12px; margin-left: auto; }
.row .who { font-size: 14px; color: var(--text-dim); }

.empty {
  border: 3px dashed var(--line);
  padding: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 16px;
}

/* ---------- chart ---------- */

.chart-box {
  position: relative;
  border: 3px solid var(--line);
  background: #05070f;
  padding: 5px;
}

.chart-box canvas { width: 100%; height: 190px; display: block; }

.chart-legend {
  display: flex;
  justify-content: space-between;
  font-family: var(--display);
  font-size: 8px;
  color: var(--text-dim);
  margin-top: 6px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.stat {
  background: var(--panel-2);
  border: 3px solid var(--line-soft);
  padding: 5px 4px;
  text-align: center;
}

.stat b { display: block; font-family: var(--display); font-size: 11px; margin-top: 3px; }
.stat span { font-size: 13px; color: var(--text-dim); }
.stat b.delta { font-size: 10px; margin-top: 2px; white-space: nowrap; }

/* ---------- table ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 16px; }
.table th, .table td { padding: 6px 6px; border-bottom: 3px solid var(--line-soft); text-align: left; }
.table th {
  font-family: var(--display);
  font-size: 7px;
  color: var(--text-dim);
  text-transform: uppercase;
  border-bottom-color: var(--line);
}
.table td.num, .table th.num { text-align: right; font-family: var(--display); font-size: 10px; }
.table tr:hover td { background: rgba(58, 209, 255, .05); }
.table .cell-sub { font-size: 13px; color: var(--text-dim); }

.pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 9px; }
.pager a, .pager span {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 7px;
  border: 3px solid var(--line);
  background: var(--panel-2);
  font-family: var(--display);
  font-size: 8px;
  color: var(--text);
}
.pager .current { border-color: var(--accent); color: var(--accent); }
.pager .disabled { opacity: .4; }

/* ---------- avatar picker ---------- */

.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 7px; }

.picker label {
  margin: 0;
  cursor: pointer;
  display: block;
  border: 3px solid var(--line);
  background: var(--panel-2);
  padding: 3px;
  transition: border-color .12s, transform .12s;
}

.picker label:hover { border-color: var(--accent); transform: translateY(-2px); }
.picker img { width: 100%; display: block; }
.picker input { display: none; }
.picker input:checked + img { outline: 4px solid var(--lime); outline-offset: -2px; }

/* ---------- bottom nav ---------- */

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  background: rgba(8, 10, 18, .96);
  border-top: 3px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(6px);
}

.bottomnav a, .bottomnav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 4px 2px;
  background: transparent;
  border: 0;
  border-right: 3px solid var(--line-soft);
  color: var(--text-dim);
  font-family: var(--display);
  font-size: 6px;
  text-transform: uppercase;
  cursor: pointer;
}

.bottomnav a:last-child, .bottomnav button:last-child { border-right: 0; }
.bottomnav form { flex: 1; display: flex; margin: 0; }
.bottomnav a.active { color: var(--accent); background: rgba(58, 209, 255, .08); }
.bottomnav .ico { font-size: 17px; line-height: 1; }

/* ---------- install hint (PWA) ---------- */

.install-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 3px solid var(--accent);
  background: rgba(58, 209, 255, .08);
  padding: 7px 8px;
  margin-bottom: 9px;
  animation: rise .22s ease-out both;
}

.install-hint[hidden] { display: none; }

.install-hint b {
  display: block;
  font-family: var(--display);
  font-size: 8px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.install-hint p { margin: 0; font-size: 15px; color: var(--text); }
.install-hint .ico { font-size: 20px; line-height: 1; }
.install-hint .grow { flex: 1; min-width: 0; }
.install-hint .btn { flex: 0 0 auto; }

/* ---------- login ---------- */

.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.login-box { width: 100%; max-width: 400px; }

.logo {
  text-align: center;
  margin-bottom: 12px;
  animation: rise .4s ease-out both;
}

.logo .title {
  font-family: var(--display);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  text-shadow: 3px 3px 0 #050713, 0 0 22px rgba(58, 209, 255, .35);
}

.logo .sub { font-size: 16px; color: var(--text-dim); margin-top: 4px; }

/* ---------- badge ---------- */

.badge {
  display: inline-block;
  padding: 1px 6px;
  border: 3px solid var(--line);
  font-family: var(--display);
  font-size: 6px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.badge.admin { border-color: var(--yellow); color: var(--yellow); }
.badge.parent { border-color: var(--violet); color: #dcc4ff; }
.badge.child { border-color: var(--accent); color: #b6ebff; }
.badge.off { border-color: var(--danger); color: #ffbcbc; }
.badge.ok { border-color: var(--ok); color: #bcffdc; }

details.block { border: 3px solid var(--line-soft); padding: 7px; background: var(--panel-2); margin-bottom: 8px; }
details.block > summary { cursor: pointer; font-family: var(--display); font-size: 8px; }

.pw-banner {
  border: 3px solid var(--lime);
  background: rgba(140, 255, 58, .08);
  padding: 9px;
  margin-bottom: 9px;
}

.pw-banner code {
  font-family: var(--display);
  font-size: 11px;
  color: var(--lime);
  word-break: break-all;
}

/* ---------- animations ---------- */

@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .15; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  70% { transform: scale(.99); }
  100% { transform: scale(1); }
}
@keyframes spark {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.4); }
}

.spark {
  position: fixed;
  width: 9px;
  height: 9px;
  z-index: 900;
  pointer-events: none;
  animation: spark .7s steps(5, end) forwards;
}

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

@media (max-width: 380px) {
  html, body { font-size: 17px; }
  .weight-input { font-size: 30px !important; }
  .key { min-height: 46px; font-size: 16px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 620px) {
  :root { --shadow: 4px 4px 0 0 #050713; }
  .wrap { padding: 10px 12px 6px; }
  .card { padding: 12px; }
  .weight-input { font-size: 46px !important; }
  .bottomnav a, .bottomnav button { min-height: 60px; font-size: 7px; }
}
