:root {
  --bg: #f2f2f7; --card: #ffffff; --chip: #ededf2; --seg: #e3e3e8; --segon: #ffffff;
  --text: #1d1d1f; --sub: #636366; --line: #e5e5ea; --line2: #c7c7cc;
  --accent: #0a66d6; --accentsoft: rgba(10, 102, 214, 0.12);
  --good: #1a7f37; --warn: #a34a00;
  --g-bg: #e6f4ea; --g-fg: #1a7f37;
  --b-bg: #e6f0fb; --b-fg: #0a5fc2;
  --o-bg: #fdf0e3; --o-fg: #a34a00;
  --n-bg: #efeff2; --n-fg: #55555b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #16161a; --chip: #2c2c2e; --seg: #1c1c1e; --segon: #3a3a3c;
    --text: #f5f5f7; --sub: #a1a1a6; --line: #2c2c2e; --line2: #3a3a3c;
    --accent: #2f7fe0; --accentsoft: rgba(77, 159, 255, 0.18);
    --good: #5cd68a; --warn: #ffb45c;
    --g-bg: #12301c; --g-fg: #5cd68a;
    --b-bg: #0f2742; --b-fg: #7ab8ff;
    --o-bg: #3a2410; --o-fg: #ffb45c;
    --n-bg: #2c2c2e; --n-fg: #b4b4ba;
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { background: var(--bg); }
body {
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

#app {
  max-width: 1180px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column; gap: 12px;
  transition: transform 0.2s ease;
}

.grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; }
.sub { color: var(--sub); font-size: 12px; }
.muted { color: var(--sub); }
.good { color: var(--good); }
.warn { color: var(--warn); }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.name { font-weight: 600; font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.kicker { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.accent { color: var(--accent); }
.status { padding: 0 4px; margin-top: -6px; }

/* Header */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 16px 4px 0; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: 0.05em; }
h1 { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -0.025em; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--card); color: var(--accent); display: grid; place-items: center; }

/* Sign in */
.signin { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.primary { border: none; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; padding: 12px 16px; min-height: 44px; }

/* One thing today */
.onething { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; background: var(--accent); color: #fff; }
.onething-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, 0.18); display: grid; place-items: center; }
.onething .grow { display: flex; flex-direction: column; gap: 1px; }
.onething .kicker { opacity: 0.85; }
.onething-t { font-size: 15px; font-weight: 600; line-height: 20px; }
.onething-d { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; opacity: 0.9; }

/* Chart tiles */
.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile-ring { align-items: center; padding: 10px 6px; }
.tlabel { font-size: 11px; color: var(--sub); }
.tbig { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tname { font-size: 11px; font-weight: 600; }
.tnote { font-size: 10px; color: var(--sub); text-align: center; }
.tile-cost .tnote { text-align: left; }
.spark-area { fill: var(--accentsoft); }
.spark-line { stroke: var(--accent); }
.budget { height: 4px; border-radius: 2px; background: var(--chip); overflow: hidden; }
.budget span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.budget span.warnbar { background: var(--o-fg); }
.ringwrap { position: relative; }
.ringnum { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 700; }
.ring-track { stroke: var(--chip); }
.ring-green { stroke: var(--g-fg); } .ring-blue { stroke: var(--b-fg); } .ring-orange { stroke: var(--o-fg); } .ring-grey { stroke: var(--n-fg); }
.legend { display: none; }
.lg { display: inline-flex; align-items: center; gap: 3px; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 3px; }
.dot.tone-green { background: var(--g-fg); } .dot.tone-blue { background: var(--b-fg); } .dot.tone-orange { background: var(--o-fg); } .dot.tone-grey { background: var(--n-fg); }
.wide-only { display: none; }
.dbrow { display: grid; grid-template-columns: 90px 1fr 18px; align-items: center; gap: 6px; font-size: 12px; }
.dbname { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.dbbar { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.dbbar span { display: block; height: 100%; background: var(--accent); }

/* Segmented controls */
.seg { display: flex; gap: 2px; padding: 3px; background: var(--seg); border-radius: 10px; }
.seg button { flex: 1; min-height: 34px; border: none; border-radius: 8px; background: transparent; color: var(--sub); font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--segon); color: var(--text); }

/* App list */
.groups { display: flex; flex-direction: column; gap: 12px; }
.group-card { padding: 4px 14px; }
.grouphead { display: flex; justify-content: space-between; padding: 10px 0 2px; font-size: 11px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: 0.05em; }
.grouphead .cnt { text-transform: none; letter-spacing: 0; }
.approw2 { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); transition: opacity 0.2s; }
.grouphead + .approw2 { border-top: none; }
.approw2.faded { opacity: 0.35; }
.appicon { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.appicon.big { width: 48px; height: 48px; border-radius: 13px; }
.tone-green { background: var(--g-bg); color: var(--g-fg); }
.tone-blue { background: var(--b-bg); color: var(--b-fg); }
.tone-orange { background: var(--o-bg); color: var(--o-fg); }
.tone-grey { background: var(--n-bg); color: var(--n-fg); }
.tone-green-fg { color: var(--g-fg); } .tone-blue-fg { color: var(--b-fg); } .tone-orange-fg { color: var(--o-fg); } .tone-grey-fg { color: var(--n-fg); }
.appname { display: flex; align-items: baseline; gap: 6px; font-size: 15px; font-weight: 600; flex-wrap: wrap; }
.stage { font-size: 11px; font-weight: 600; }
.meta { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.meta b { color: var(--text); font-weight: 600; }
.next { font-size: 12px; color: var(--sub); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.right .num { font-size: 13px; }
.small { display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 600; }

/* Bottom tiles */
.bottom { display: flex; gap: 10px; }
.mini { flex: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-radius: 16px; padding: 10px 14px; }
.mini .right { align-items: flex-end; }
.dashed { background: transparent; border: 1.5px dashed var(--line2); }

/* Detail */
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding-top: 12px; font-size: 17px; color: var(--accent); align-self: flex-start; }
.dhead { display: flex; align-items: center; gap: 12px; }
.dhead h1 { font-size: 26px; line-height: 32px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; flex: none; }
.pill .dot.tone-green, .pill .dot.tone-blue, .pill .dot.tone-orange, .pill .dot.tone-grey { background: currentColor; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border-radius: 16px; }
.sval { font-size: 17px; font-weight: 700; }
.panels > .panel { display: none; flex-direction: column; gap: 10px; }
.panels[data-tab="continue"] > [data-panel="continue"],
.panels[data-tab="tech"] > [data-panel="tech"],
.panels[data-tab="logins"] > [data-panel="logins"],
.panels[data-tab="costs"] > [data-panel="costs"] { display: flex; }
.ph { display: none; font-size: 13px; font-weight: 600; color: var(--sub); text-transform: uppercase; letter-spacing: 0.05em; }
.nextcard { background: var(--accentsoft); border: none; display: flex; flex-direction: column; gap: 4px; }
.nexttitle { font-size: 17px; font-weight: 600; }
.linkrow { display: flex; gap: 8px; flex-wrap: wrap; }
.linkbtn { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 13px; font-weight: 500; }
.note { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.flow { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.flowbox { padding: 8px 12px; border-radius: 10px; background: var(--chip); font-size: 13px; font-weight: 600; }
.flowarrow { align-self: center; color: var(--sub); }
.kvgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.kv { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kvv { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.info { display: flex; gap: 10px; align-items: center; background: var(--accentsoft); border: none; font-size: 13px; color: var(--text); }
.info svg { flex: none; color: var(--accent); }
.list { padding: 2px 14px; }
.loginrow { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.loginrow:first-child { border-top: none; }
.rowsb { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; }
.list .rowsb + .rowsb { border-top: 1px solid var(--line); }
.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 110px; border-bottom: 1px solid var(--line); margin-top: 8px; }
.bar { border-radius: 3px 3px 0 0; background: var(--b-bg); }
.bar.cur { background: var(--accent); }
.barlabels { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; margin-top: 4px; }
.barlabels span { font-size: 10px; text-align: center; color: var(--sub); }

/* Mac and wide screens: four tiles, groups side by side, all detail panels at once */
@media (min-width: 900px) {
  #app { padding-left: 32px; padding-right: 32px; }
  .tiles { grid-template-columns: 1.3fr 1fr 1fr 1.3fr; gap: 12px; }
  .tile { padding: 14px 16px; }
  .tile-ring { flex-direction: column; }
  .legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 8px; font-size: 10px; color: var(--sub); }
  .wide-only { display: flex; }
  .seg:not(.tabs) { max-width: 360px; }
  .groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
  .view-detail .tabs { display: none; }
  .view-detail .ph { display: block; }
  .panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .panels > .panel { display: flex !important; }
  .stats { max-width: 640px; }
}

/* Pull-to-refresh */
.ptr {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%;
  transform: translate(-50%, -60px); width: 40px; height: 40px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); color: var(--accent);
  display: grid; place-items: center; z-index: 10; opacity: 0;
}
.ptr.spin .ptr-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  #app, .approw2 { transition: none; }
  .ptr.spin .ptr-icon { animation: none; }
}
[hidden] { display: none !important; }
.meta svg, .small svg, .sub svg, .dbname svg, .onething-d svg { flex: none; }
.hbtns { display: flex; gap: 8px; }

/* Quick list */
:root { --r-bg: #fdecec; --r-fg: #c4271f; }
@media (prefers-color-scheme: dark) { :root { --r-bg: #3a1414; --r-fg: #ff6b61; } }
.tone-red { background: var(--r-bg); color: var(--r-fg); }
.tone-red-fg { color: var(--r-fg); }
.dot.tone-red { background: var(--r-fg); }
.viewseg { max-width: 360px; }
.summary { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 4px; font-size: 13px; font-weight: 600; }
.sumitem { display: inline-flex; align-items: center; gap: 6px; }
.qlist { padding: 2px 14px; }
.qrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 44px; }
.qrow:first-child { border-top: none; }
.qname { font-size: 15px; font-weight: 600; }
.spill { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.spill .dot { background: currentColor; }
@media (min-width: 900px) { .qlist { max-width: 760px; } }

.updatebar { display: block; width: 100%; border: none; border-radius: 12px; padding: 10px 14px; min-height: 44px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; text-align: center; }
.updatebar.done { background: var(--g-bg); color: var(--g-fg); }
