/* =========================================================
   煦之 · Life Panel — Design System
   Style anchor: Linear × Apple Health × Copilot Money
   Deep ink canvas · warm gold currency · mint vitality
   ========================================================= */

:root {
  --bg: #070B12;
  --bg-elevated: #0B111B;
  --surface: #0F1522;
  --card: #121A2A;
  --card-hover: #162033;
  --line: rgba(148, 170, 200, 0.12);
  --line-strong: rgba(148, 170, 200, 0.22);

  --ink: #EEF3FA;
  --ink-soft: #C5D0E0;
  --muted: #7E90A8;
  --faint: #5A6A80;

  --gold: #E4B354;
  --gold-dim: rgba(228, 179, 84, 0.14);
  --mint: #3DDC97;
  --mint-dim: rgba(61, 220, 151, 0.14);
  --sky: #5B9DFF;
  --sky-dim: rgba(91, 157, 255, 0.14);
  --coral: #FF7A6E;
  --coral-dim: rgba(255, 122, 110, 0.14);
  --violet: #A78BFA;
  --violet-dim: rgba(167, 139, 250, 0.14);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;

  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "SF Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;

  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.28);

  --max: 1180px;
  --pad: clamp(16px, 3vw, 32px);
}

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

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(228, 179, 84, 0.08), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(91, 157, 255, 0.08), transparent 50%),
    radial-gradient(800px 700px at 50% 110%, rgba(61, 220, 151, 0.05), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-authed {
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

/* ---------- ambient ---------- */
.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.aurora span {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  animation: drift 18s ease-in-out infinite alternate;
}

.aurora .a1 {
  width: 420px;
  height: 420px;
  background: rgba(228, 179, 84, 0.18);
  top: -80px;
  left: -60px;
}

.aurora .a2 {
  width: 380px;
  height: 380px;
  background: rgba(91, 157, 255, 0.16);
  top: 10%;
  right: -80px;
  animation-delay: -6s;
}

.aurora .a3 {
  width: 320px;
  height: 320px;
  background: rgba(61, 220, 151, 0.12);
  bottom: -40px;
  left: 30%;
  animation-delay: -11s;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(24px, -30px, 0) scale(1.08); }
}

/* ---------- login ---------- */
#login-view {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--pad);
}

.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(18, 26, 42, 0.92), rgba(12, 18, 30, 0.96));
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.login-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background: linear-gradient(145deg, rgba(228, 179, 84, 0.25), rgba(228, 179, 84, 0.05));
  border: 1px solid rgba(228, 179, 84, 0.35);
  color: var(--gold);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card .sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(7, 11, 18, 0.55);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: rgba(228, 179, 84, 0.55);
  box-shadow: 0 0 0 3px rgba(228, 179, 84, 0.12);
}

.btn {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, #f0c56a, #d4a03a);
  color: #1a1408;
  box-shadow: 0 10px 28px rgba(228, 179, 84, 0.22);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.login-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--coral);
  font-size: 13px;
}

.login-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- app shell ---------- */
#app-view {
  position: relative;
  z-index: 1;
  display: none;
  min-height: 100vh;
}

body.is-authed #login-view {
  display: none;
}

body.is-authed #app-view {
  display: block;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(7, 11, 18, 0.72);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 14px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(228, 179, 84, 0.22), rgba(228, 179, 84, 0.04));
  border: 1px solid rgba(228, 179, 84, 0.3);
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(15, 21, 34, 0.8);
  color: var(--ink-soft);
  font-size: 12px;
}

.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px rgba(61, 220, 151, 0.7);
}

.btn-ghost {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 12px;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--pad) 60px;
}

/* ---------- bento ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, rgba(18, 26, 42, 0.92), rgba(14, 20, 32, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
  transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: var(--line-strong);
}

.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-head .meta {
  font-size: 11px;
  color: var(--faint);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tag.gold { background: var(--gold-dim); color: var(--gold); }
.tag.mint { background: var(--mint-dim); color: var(--mint); }
.tag.sky { background: var(--sky-dim); color: var(--sky); }
.tag.coral { background: var(--coral-dim); color: var(--coral); }
.tag.violet { background: var(--violet-dim); color: var(--violet); }

/* hero */
.hero {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr 0.9fr;
  gap: 16px;
}

.profile-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 18px;
  align-items: center;
}

.avatar {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.14), transparent 40%),
    linear-gradient(145deg, #2a3550, #151d30);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 750;
  color: var(--gold);
  letter-spacing: -0.04em;
}

.profile-card h3 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.profile-card .role {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.kv-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kv {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}

.metric-big {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 4px;
}

.metric-big .num {
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-big .unit {
  color: var(--muted);
  font-size: 13px;
}

.metric-big .caption {
  color: var(--faint);
  font-size: 12px;
  margin-top: 4px;
}

/* weight ring */
.ring-wrap {
  position: relative;
  width: 148px;
  height: 148px;
  margin: 0 auto;
}

.ring-wrap svg {
  width: 148px;
  height: 148px;
  transform: rotate(-90deg);
}

.ring-wrap .ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 10;
}

.ring-wrap .ring-fg {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}

.ring-center .n {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.ring-center .s {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* progress bars */
.bar-row {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.bar-row:last-child {
  margin-bottom: 0;
}

.bar-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.bar-top .left {
  color: var(--ink-soft);
}

.bar-top .right {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  width: 0;
  transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-fill.gold { background: linear-gradient(90deg, #f0c56a, #d4a03a); }
.bar-fill.sky { background: linear-gradient(90deg, #7db1ff, #4a8af0); }
.bar-fill.mint { background: linear-gradient(90deg, #5fe0ab, #2bc884); }
.bar-fill.coral { background: linear-gradient(90deg, #ff9a90, #ef6a5e); }

/* stats strip */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat {
  padding: 14px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  text-align: center;
}

.stat .n {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat .l {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

/* list */
.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
}

.list-item .t {
  font-size: 13px;
  line-height: 1.5;
}

.list-item .s {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.list-item .side {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  cursor: default;
}

.check-item .box {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  margin-top: 2px;
  flex: 0 0 auto;
}

.check-item.done .box {
  background: var(--mint);
  border-color: var(--mint);
  box-shadow: inset 0 0 0 2px #0b1a14;
}

.check-item.done .t {
  color: var(--faint);
  text-decoration: line-through;
}

/* menu grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.menu-day {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  padding: 12px 10px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-day.today {
  border-color: rgba(228, 179, 84, 0.5);
  background: linear-gradient(180deg, rgba(228, 179, 84, 0.12), rgba(228, 179, 84, 0.03));
  box-shadow: 0 0 0 1px rgba(228, 179, 84, 0.08);
}

.menu-day.weekend {
  background: rgba(91, 157, 255, 0.05);
}

.menu-day .d {
  font-size: 12px;
  color: var(--gold);
  font-weight: 650;
}

.menu-day .date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.menu-day .dish {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* chart */
.chart-wrap {
  height: 220px;
  width: 100%;
  position: relative;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

/* table */
.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data th,
table.data td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

table.data th {
  color: var(--faint);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
}

table.data td {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

table.data td.num {
  font-family: var(--mono);
  font-size: 12px;
}

table.data tr:last-child td {
  border-bottom: 0;
}

/* birthday timeline */
.bday-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.bday {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.bday .nm {
  font-weight: 650;
  font-size: 14px;
  margin-bottom: 4px;
}

.bday .nt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.bday .dt {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--violet);
}

.bday .days {
  margin-top: 6px;
  font-size: 11px;
  color: var(--faint);
}

.bday.soon {
  border-color: rgba(167, 139, 250, 0.4);
  background: rgba(167, 139, 250, 0.08);
}

/* tips */
.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.tips li + li {
  margin-top: 4px;
}

/* health timeline */
.timeline {
  display: grid;
  gap: 0;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line-strong);
}

.tl-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  padding-bottom: 16px;
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--bg);
  margin-top: 3px;
  z-index: 1;
}

.tl-item.watch .tl-dot { border-color: var(--sky); }
.tl-item.warn .tl-dot { border-color: var(--coral); }
.tl-item.ok .tl-dot { border-color: var(--mint); }

.tl-body .d {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

.tl-body .t {
  font-size: 13px;
  font-weight: 600;
  margin: 2px 0;
}

.tl-body .s {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

/* metric flags */
.flag-list {
  display: grid;
  gap: 8px;
}

.flag-row {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 0.8fr 0.9fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  font-size: 12px;
}

.flag-row .name { color: var(--ink-soft); }
.flag-row .val {
  font-family: var(--mono);
  font-weight: 650;
  color: var(--ink);
}
.flag-row .ref { color: var(--faint); }
.flag-row .st {
  justify-self: end;
}

/* footer */
.footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 8px var(--pad) 36px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--faint);
  font-size: 11px;
}

/* focus pills */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  color: var(--ink-soft);
}

/* responsive */
@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .span-8, .span-7, .span-6, .span-5, .span-4, .span-3 {
    grid-column: span 12;
  }
  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .bday-grid {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .flag-row {
    grid-template-columns: 1fr 1fr;
  }
  .flag-row .st { justify-self: start; }
}

@media (max-width: 560px) {
  .profile-card {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
  .menu-grid {
    grid-template-columns: 1fr;
  }
  .metric-big .num {
    font-size: 34px;
  }
}

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