@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("assets/fonts/plus-jakarta-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #171C26;
  --surface: #222A36;
  --elevated: #2B3543;
  --card: #303B4E;
  --card-lilac: #3A3450;
  --accent: #8E82C9;
  --teal: #69A6A0;
  --warm: #C98272;
  --soft: #7F9FC4;
  --gold: #C5A56E;
  --text: #F2F0EB;
  --text2: #AEB2BF;
  --muted: #747D8C;
  --caption: #B4BAC8;
  --divider: #394453;
  --lilac-deep: #4E456E;
  --lilac-dark: #6A5F96;
  --lilac-soft: #ADA4DC;
  --lilac-pale: #C9C2EB;
  --outline: rgba(242, 240, 235, .14);
  --radius: 18px;
  --nav-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #10141b;
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.43;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg.i { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }

#app {
  position: relative;
  max-width: 600px;
  height: 100%;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, .4);
}

/* App bar */
.appbar {
  flex: none;
  display: flex;
  align-items: center;
  min-height: calc(56px + var(--safe-t));
  padding: var(--safe-t) 4px 0 4px;
  background: var(--bg);
  z-index: 3;
}
.appbar .title {
  flex: 1;
  min-width: 0;
  font-size: 22px;
  font-weight: 400;
  padding: 0 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar .back + .title { padding-left: 4px; }
.icon-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text2);
  flex: none;
  transition: background .15s;
}
.appbar .icon-btn { color: var(--text); }
.icon-btn:hover { background: rgba(255, 255, 255, .06); }
.icon-btn:active { background: rgba(255, 255, 255, .12); }
.icon-btn:disabled { color: var(--muted); cursor: default; background: none; }

.battery {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px; border-radius: 24px;
  color: var(--text2); font-size: 13px; margin-right: 4px;
}
.battery .i { width: 22px; height: 22px; }
.battery.low { color: var(--gold); }
.battery.critical { color: var(--warm); }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse .9s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }

/* Body */
.body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-top: 16px;
  padding-bottom: 24px;
}
.body.tab { padding-bottom: calc(96px + var(--safe-b)); }
.body.detail { padding: 16px 16px calc(24px + var(--safe-b)); }

/* Bottom navigation (Material 3) */
.navbar {
  flex: none;
  display: flex;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  z-index: 3;
}
.navbar[hidden] { display: none; }
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px; font-weight: 500; line-height: 1.15;
}
.nav-item .pill {
  width: 64px; height: 32px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.nav-item.on { color: var(--accent); font-size: 12.5px; font-weight: 600; }
.nav-item.on .pill { background: rgba(142, 130, 201, .24); }
.nav-item.on .i { width: 26px; height: 26px; }

.fab {
  position: absolute;
  right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
  z-index: 4;
  transition: transform .15s;
}
.fab:active { transform: scale(.95); }
.fab[hidden] { display: none; }

/* Cards */
.card {
  margin: 0 16px 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #354158 0%, var(--card) 50%, var(--card-lilac) 100%);
  border: 1px solid var(--outline);
  overflow: hidden;
}
.card.filters { padding: 16px 0; }
.card.filters > .lbl, .card.filters > .h { padding: 0 16px; }
.detail .card { margin-left: 0; margin-right: 0; }
.card-tap { display: block; width: 100%; text-align: left; transition: filter .15s; }
.card-tap:hover { filter: brightness(1.06); }
.card-tap:active { filter: brightness(1.12); }
.stack { margin: 0 16px 12px; }
.detail .stack { margin: 0 0 12px; }
.stack > .card { margin: 0; }

.h { font-size: 16px; font-weight: 500; margin: 0 0 16px; }
.h.s { font-size: 14px; margin-bottom: 12px; }
.h.b { font-weight: 600; margin-bottom: 8px; }
.lbl { color: var(--muted); font-size: 12px; margin: 12px 0 8px; }
.muted { color: var(--muted); }
.sec { color: var(--text2); }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.sb { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Scene banner */
.banner {
  margin: 0 16px 16px;
  padding: .5px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(242,240,235,.07), rgba(242,240,235,.04) 55%, rgba(142,130,201,.05));
  border: .5px solid rgba(242, 240, 235, .14);
}
.detail .banner { margin-left: 0; margin-right: 0; }
.banner-in {
  position: relative;
  height: var(--h, 168px);
  border-radius: 17.5px;
  overflow: hidden;
  background: var(--elevated);
}
.banner-in img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-in::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; z-index: 1;
  background: linear-gradient(90deg, rgba(242,240,235,.14), rgba(242,240,235,0));
}
.banner-in::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 48%;
  background: linear-gradient(transparent, rgba(23, 28, 38, .82));
}
.banner-txt { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 2; }
.banner-txt .t { font-size: 18px; font-weight: 500; }
.banner-txt .s { color: var(--text2); font-size: 13px; margin-top: 8px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-scroll {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 0 16px;
  scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll::after { content: ""; flex: 0 0 4px; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(58,52,80,.55), rgba(48,59,78,.45));
  border: 1px solid rgba(142, 130, 201, .22);
  color: var(--caption);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  transition: filter .15s;
}
.chip:hover { filter: brightness(1.12); }
.chip.on {
  background: linear-gradient(90deg, rgba(142,130,201,.32), rgba(142,130,201,.22));
  border-color: rgba(173, 164, 220, .55);
  color: var(--text);
  font-weight: 600;
}
.chip .dot { width: 12px; height: 12px; border-radius: 50%; }
.pchip .av { width: 24px; height: 24px; font-size: 9px; border: 2px solid transparent; box-sizing: content-box; }
.pchip.on {
  background: linear-gradient(90deg, rgba(142,130,201,.55), rgba(142,130,201,.42));
  border: 2px solid var(--lilac-pale);
  padding: 9px 12px; margin: -1px 0;
  font-size: 14px;
}
.pchip.on .av { border-color: var(--text); }
.pchip .i { width: 18px; height: 18px; }
.toggle { display: flex; gap: 6px; flex: none; }

/* Avatars */
.av {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text); font-weight: 700; font-size: 14px; flex: none;
  line-height: 1;
}

/* Overview */
.level { background: var(--elevated); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.level:last-child { margin-bottom: 0; }
.level .dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.level .name { font-weight: 500; flex: 1; }
.markers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.marker { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px 2px 0; border-radius: 12px; font-size: 14px; transition: background .15s; }
.marker:hover { background: var(--surface); }
.marker .tap { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.marker .av { width: 28px; height: 28px; font-size: 13px; font-weight: 600; }
.stat { display: flex; justify-content: space-between; margin-bottom: 8px; gap: 12px; }
.stat:last-child { margin-bottom: 0; }
.stat span:first-child { color: var(--text2); }
.metrics { display: flex; gap: 12px; }
.metric { flex: 1; background: var(--elevated); border-radius: 12px; padding: 12px; }
.metric .v { font-size: 22px; font-weight: 500; margin-top: 4px; }
.tile {
  display: flex; align-items: center; gap: 16px;
  width: 100%; text-align: left;
  padding: 8px 0; min-height: 48px;
  border-radius: 8px;
}
.tile.pad { padding: 8px 16px; }
.tile.tap:hover { background: rgba(255,255,255,.04); }
.tile .tt { font-size: 16px; }
.tile .st { color: var(--text2); font-size: 14px; white-space: pre-line; }
.tile.dense .tt { font-size: 14px; }
.tile.dense .st { font-size: 12.5px; color: var(--caption); }
.tile .av.sm { width: 32px; height: 32px; font-size: 11px; font-weight: 500; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; padding: 0 24px;
  border-radius: 999px;
  font-size: 14px; font-weight: 500; letter-spacing: .1px;
  transition: filter .15s;
}
.btn.r12 { border-radius: 12px; }
.btn.fill { background: var(--accent); color: #000; }
.btn.fill.light { color: var(--text); }
.btn.fill:hover { filter: brightness(1.08); }
.btn.fill:disabled { background: rgba(242,240,235,.12); color: rgba(242,240,235,.38); filter: none; cursor: default; }
.btn.outline { border: 1px solid var(--muted); color: var(--accent); }
.btn.outline.teal { border-color: var(--teal); color: var(--teal); }
.btn.text { color: var(--accent); min-height: 40px; }
.btn.text.warm { color: var(--warm); }
.btn.inline { display: inline-flex; width: auto; min-height: 40px; }
.btn:hover:not(.fill) { background: rgba(142,130,201,.08); }
.gap12 { height: 12px; }
.gap24 { height: 24px; }

/* Person card */
.pcard .top { display: flex; align-items: flex-start; gap: 12px; }
.pcard .ring { border-radius: 50%; border: 2px solid; flex: none; }
.pcard .nm { font-size: 16px; font-weight: 600; }
.pcard .sub { color: var(--caption); font-size: 12.5px; line-height: 1.25; margin-top: 4px; }
.cpill { padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; flex: none; }
.snippet { color: var(--text2); font-size: 13px; line-height: 1.35; margin-top: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cells { display: flex; gap: 8px; margin-top: 12px; }
.cell { flex: 1; min-width: 0; padding: 8px; border-radius: 10px; background: rgba(142,130,201,.07); border: 1px solid rgba(142,130,201,.12); }
.cell .l { color: var(--muted); font-size: 10px; line-height: 1.1; }
.cell .v { font-size: 12px; font-weight: 500; line-height: 1.15; margin-top: 2px; }

/* Interaction card */
.icard .dt { color: var(--text2); font-size: 13px; }
.icard .ppl { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.icard .ppl .av { width: 28px; height: 28px; font-size: 10px; font-weight: 400; }
.icard .ppl .names { margin-left: 4px; }
.icard .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.tpill { padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.imp { display: inline-flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.imp i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.icard .note { color: var(--muted); margin-top: 8px; }

.group-h { padding: 12px 16px 8px; }
.group-h span {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(142,130,201,.22), rgba(78,69,110,.12));
  border: 1px solid rgba(173,164,220,.2);
  font-size: 13px; font-style: italic; font-weight: 500; line-height: 1.1;
}
.group-h b {
  font-weight: 500;
  background: linear-gradient(90deg, var(--lilac-pale), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.empty { text-align: center; color: var(--muted); }
.empty .i { width: 48px; height: 48px; margin: 0 auto 12px; color: var(--muted); }
.empty .btn { margin: 16px auto 0; width: auto; display: inline-flex; min-height: 40px; }

/* Forms */
.field { position: relative; margin-bottom: 24px; }
.field.nomb { margin-bottom: 0; }
.input {
  width: 100%;
  background: var(--elevated);
  border: 1px solid var(--outline);
  border-radius: 14px;
  padding: 16px 12px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  resize: vertical;
  transition: border-color .15s;
}
.input:focus { border-color: rgba(142,130,201,.65); }
.input::placeholder { color: var(--muted); }
.field label {
  display: block;
  color: var(--text2);
  font-size: 12px;
  margin: 0 0 6px 4px;
}
.counter { text-align: right; color: var(--text2); font-size: 12px; margin-top: 4px; padding-right: 12px; }
.fsec { margin-bottom: 24px; }
.fsec.md { margin-bottom: 16px; }
.fsec > .ft { color: var(--text2); font-size: 14px; font-weight: 500; margin-bottom: 12px; }
.hint { color: rgba(201,130,114,.9); font-size: 13px; margin-bottom: 12px; }
.avatar-lg { display: flex; flex-direction: column; align-items: center; }
.date-row { display: flex; align-items: center; min-height: 56px; }
.date-row .grow { font-size: 16px; }
.date-pick { position: relative; }
.date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* Details */
.d-head { display: flex; flex-direction: column; align-items: center; text-align: center; }
.dsec { padding-top: 24px; }
.dsec > .t { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.dsec > .card, .dsec > .stack { margin: 0 0 12px; }
.dsec > :last-child { margin-bottom: 0; }

/* Progress */
.prog { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.prog i { display: block; height: 100%; border-radius: 999px; }
.lvl-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.lvl-row:last-child { margin-bottom: 0; }
.lvl-row .n { flex: 2; color: var(--text2); }
.lvl-row .n.on { color: var(--text); font-weight: 500; }
.lvl-row .prog { flex: 3; }

/* Charts */
.chart-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.axis { display: flex; justify-content: space-between; color: var(--caption); font-size: 11.5px; font-weight: 500; margin-top: 8px; }
.donut { display: flex; align-items: center; gap: 16px; }
.legend { flex: 1; min-width: 0; }
.legend .li { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.legend .li:last-child { margin-bottom: 0; }
.legend .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend .sw.bar { width: 12px; height: 4px; border-radius: 2px; }
.legend .lb { flex: 1; color: var(--caption); font-size: 12.5px; font-weight: 500; }
.legend .vv { font-weight: 500; }
.rings { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 20px; }
.ring-it { width: 92px; display: flex; flex-direction: column; align-items: center; }
.ring-box { position: relative; width: 84px; height: 84px; }
.ring-box svg { position: absolute; inset: 0; }
.ring-box b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 600; }
.ring-it .lb { color: var(--caption); font-size: 11.5px; font-weight: 500; margin-top: 8px; text-align: center; }
.bars { overflow-x: auto; scrollbar-width: thin; }
.bars-in { display: flex; align-items: flex-end; height: 176px; }
.bars.scroll .bars-in { padding: 0 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bars.scroll .bar-col { flex: 0 0 48px; }
.bar-col .val { height: 20px; display: flex; align-items: center; font-size: 12px; font-weight: 500; line-height: 1.1; }
.bar-col .area { height: 122px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar-col .bar { width: 46%; border-radius: 6px; }
.bars.scroll .bar-col .bar { width: 22px; }
.bar-col .xl { height: 34px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--caption); font-size: 11.5px; font-weight: 500; line-height: 1.2; padding: 0 2px; overflow: hidden; }
.act-legend { display: flex; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(142,130,201,.08); border: 1px solid rgba(142,130,201,.16); }
.act-legend .c { min-width: 0; display: flex; flex-direction: column; }
.act-legend .c.end { align-items: flex-end; text-align: right; }
.act-legend .c .a { font-size: 11px; font-weight: 500; color: rgba(242,240,235,.88); display: flex; align-items: center; gap: 4px; max-width: 100%; }
.act-legend .c .a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-legend .c .a .i { width: 13px; height: 13px; color: var(--lilac-soft); }
.act-legend .c .b { font-size: 10px; color: var(--caption); font-weight: 500; }
.act-legend .dv { width: 1px; height: 28px; margin: 0 6px; background: rgba(142,130,201,.18); flex: none; }
.sub-h { color: var(--caption); font-size: 13px; font-weight: 500; margin-top: 16px; }

/* Overlay: sheets & dialogs */
#overlay { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s; pointer-events: auto; }
.scrim.in { opacity: 1; }
.sheet {
  position: absolute; left: 50%; bottom: 0;
  width: 100%; max-width: 600px;
  transform: translate(-50%, 100%);
  background: var(--elevated);
  border-radius: 20px 20px 0 0;
  padding: 16px 24px calc(24px + var(--safe-b));
  display: flex; flex-direction: column; gap: 12px;
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  pointer-events: auto;
  max-height: 90%;
  overflow-y: auto;
}
.sheet.in { transform: translate(-50%, 0); }
.sheet .grab { width: 32px; height: 4px; border-radius: 2px; background: var(--muted); margin: -4px auto 4px; opacity: .6; }
.sheet .big { font-size: 32px; font-weight: 700; line-height: 1.2; }
.sheet .t20 { font-size: 20px; font-weight: 600; }
.dialog {
  position: absolute; left: 50%; top: 50%;
  width: calc(100% - 48px); max-width: 360px;
  transform: translate(-50%, -50%) scale(.94);
  opacity: 0;
  background: var(--elevated);
  border-radius: 28px;
  padding: 24px;
  transition: transform .18s, opacity .18s;
  pointer-events: auto;
}
.dialog.in { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.dialog .dt { font-size: 24px; line-height: 1.3; margin-bottom: 16px; }
.dialog .dc { color: var(--text2); margin-bottom: 24px; }
.dialog .da { display: flex; justify-content: flex-end; gap: 8px; }
.dialog .da .btn { width: auto; padding: 0 12px; }
.dialog .field { margin-bottom: 16px; }
.dialog .err { color: var(--warm); font-size: 13px; margin: -8px 0 16px; }
.dialog input[type=date] { color-scheme: dark; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  transform: translate(-50%, 20px);
  width: calc(100% - 24px); max-width: 576px;
  background: #E2E2E6; color: #2F3033;
  border-radius: 4px;
  padding: 14px 16px;
  box-shadow: 0 3px 10px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
  display: flex; align-items: center; gap: 12px;
}
#toast.in { opacity: 1; transform: translate(-50%, 0); }
#toast.bat { background: var(--elevated); color: var(--text); }
#toast.bat::before { content: ""; width: 4px; height: 40px; background: var(--gold); flex: none; }
#toast.low { bottom: calc(16px + var(--safe-b)); }

@media (min-width: 601px) {
  body { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
