:root {
  --bg: #eef2f6;
  --bg-2: #e6ecf2;
  --surface: #ffffff;
  --text: #101a24;
  --muted: #64768a;
  --faint: #9aa9b8;
  --brand: #1a5f7a;
  --brand-2: #2a86a8;
  --brand-ink: #0d3547;
  --ok: #17b26a;
  --ok-ink: #05331d;
  --line: #e3e9ef;
  --shadow: 0 6px 20px rgba(16, 32, 48, .08);
  --shadow-lg: 0 18px 44px rgba(16, 32, 48, .22);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* [hidden] must always win, even over class rules like .sheet-backdrop{display:flex}.
   Otherwise hidden elements (modal, empty state, toast) stay on screen and block taps. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- Header ---- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 22px) 20px 26px;
  color: #fff;
  background: radial-gradient(140% 120% at 0% 0%, var(--brand-2), var(--brand) 55%, var(--brand-ink));
  border-radius: 0 0 26px 26px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  font-size: 22px; width: 44px; height: 44px; display: grid; place-items: center;
  background: rgba(255,255,255,.16); border-radius: 14px; backdrop-filter: blur(4px);
}
.biz { font-weight: 750; font-size: 19px; letter-spacing: -.2px; }
.sub { color: rgba(255,255,255,.72); font-size: 13px; margin-top: 1px; }
.head-right { display: flex; align-items: center; gap: 10px; }
.refresh {
  background: rgba(255,255,255,.16); border: 0; color: #fff;
  width: 42px; height: 42px; border-radius: 13px; font-size: 20px; cursor: pointer;
  transition: transform .3s ease, background .2s;
}
.refresh:active { transform: rotate(180deg); background: rgba(255,255,255,.28); }

/* ---- List ---- */
.list { padding: 18px 16px 28px; display: flex; flex-direction: column; gap: 13px; max-width: 560px; margin: 0 auto; }
.job {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr; grid-gap: 4px 14px; align-items: start;
  animation: pop .32s cubic-bezier(.2,.7,.3,1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.avatar {
  grid-row: 1 / span 2; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px;
  background: linear-gradient(150deg, var(--brand-2), var(--brand));
}
.job .who { font-weight: 700; font-size: 17px; letter-spacing: -.2px; align-self: center; }
.job .svc {
  grid-column: 2; justify-self: start;
  display: inline-block; background: #eaf4f8; color: var(--brand);
  font-size: 12px; font-weight: 650; padding: 4px 11px; border-radius: 999px; margin-top: 2px;
}
.job .meta { grid-column: 1 / -1; color: var(--muted); font-size: 13.5px; margin-top: 10px;
  display: flex; flex-direction: column; gap: 3px; }
.job .meta span { display: flex; align-items: center; gap: 7px; }
.job .meta .ico { opacity: .6; font-size: 13px; }
.job .done {
  grid-column: 1 / -1; margin-top: 14px; width: 100%;
  background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff;
  border: 0; border-radius: 14px; padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(26,95,122,.28); transition: transform .12s, filter .2s;
}
.job .done:active { transform: translateY(1px) scale(.99); filter: brightness(1.05); }
.job.removing { opacity: 0; transform: translateX(60px) scale(.96); transition: .28s cubic-bezier(.4,0,1,1); }

/* count pill */
.count { background: rgba(255,255,255,.18); color:#fff; font-size:13px; font-weight:700;
  padding: 3px 10px; border-radius: 999px; }

/* ---- Empty ---- */
.empty { text-align: center; color: var(--muted); margin: 22vh auto 0; max-width: 300px; }
.empty-emoji { font-size: 52px; }
.empty p { font-size: 16px; }

/* ---- Bottom sheet ---- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(10,20,30,.5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 560px; background: var(--surface); color: var(--text);
  border-radius: 26px 26px 0 0; padding: 10px 22px calc(env(safe-area-inset-bottom) + 24px);
  box-shadow: var(--shadow-lg); animation: up .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes up { from { transform: translateY(60px); } to { transform: none; } }
.sheet-handle { width: 42px; height: 5px; background: var(--line); border-radius: 999px; margin: 8px auto 14px; }
.sheet h2 { margin: 2px 0 3px; font-size: 21px; letter-spacing: -.3px; }
.sheet-job { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.sheet label { font-size: 13px; color: var(--muted); font-weight: 600; }
.money {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 18px; margin: 8px 0 22px;
  transition: border-color .15s, box-shadow .15s;
}
.money:focus-within { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(42,134,168,.14); }
.money .cur { font-size: 26px; color: var(--faint); font-weight: 600; }
.money input {
  flex: 1; background: transparent; border: 0; color: var(--text);
  font-size: 30px; font-weight: 750; outline: none; letter-spacing: -.5px; min-width: 0;
}
.sheet-actions { display: flex; gap: 12px; }
.btn { border: 0; border-radius: 15px; padding: 15px 16px; font-size: 16px; font-weight: 700; cursor: pointer; transition: transform .12s, filter .2s; }
.btn:active { transform: translateY(1px) scale(.99); }
.sheet-actions .btn { flex: 1; }
.btn.primary { background: linear-gradient(180deg, var(--ok), #12a05e); color: #fff; box-shadow: 0 6px 16px rgba(23,178,106,.3); }
.btn.primary:disabled { filter: grayscale(.4) brightness(.95); opacity: .8; }
.btn.ghost { background: var(--bg); color: var(--muted); }

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 22px); left: 50%;
  transform: translateX(-50%); background: #101a24; color: #fff;
  padding: 13px 20px; border-radius: 999px; font-weight: 650; font-size: 14.5px; z-index: 30;
  box-shadow: var(--shadow-lg); animation: toastin .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- Views + bottom tab bar ---- */
.view { padding-bottom: 82px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 15;
  display: flex; background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px);
}
.tab {
  flex: 1; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--faint); font-size: 11.5px; font-weight: 650; padding: 6px; border-radius: 12px;
  transition: color .15s;
}
.tab .ti { font-size: 20px; filter: grayscale(1) opacity(.6); transition: filter .15s; }
.tab.active { color: var(--brand); }
.tab.active .ti { filter: none; }

/* ---- Report dashboard ---- */
.report { padding: 18px 16px; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.rng { display: flex; gap: 8px; align-items: center; }
.rng .chip {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 8px 13px; border-radius: 999px; cursor: pointer;
}
.rng .chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.hero-kpi {
  background: radial-gradient(120% 120% at 100% 0%, var(--brand-2), var(--brand) 70%, var(--brand-ink));
  color: #fff; border-radius: 20px; padding: 20px; box-shadow: var(--shadow);
}
.hero-kpi .lbl { font-size: 13px; opacity: .82; font-weight: 600; }
.hero-kpi .big { font-size: 40px; font-weight: 800; letter-spacing: -1px; margin-top: 2px; }
.hero-kpi .sub2 { font-size: 13.5px; opacity: .85; margin-top: 4px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 15px; box-shadow: var(--shadow);
}
.kpi .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 750; letter-spacing: -.5px; margin-top: 3px; }
.kpi .val small { font-size: 14px; color: var(--faint); font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 17px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 15px; letter-spacing: -.2px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 10px; margin: 9px 0; font-size: 13.5px; }
.bar-row .nm { color: var(--muted); text-transform: capitalize; }
.bar-track { height: 9px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-2), var(--brand)); }
.bar-row .n { font-weight: 700; color: var(--text); }
.spend { display: flex; align-items: center; gap: 8px; background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 15px; margin-top: 6px; }
.spend:focus-within { border-color: var(--brand-2); box-shadow: 0 0 0 4px rgba(42,134,168,.14); }
.spend .cur { color: var(--faint); font-size: 20px; font-weight: 600; }
.spend input { flex: 1; border: 0; background: transparent; outline: none; font-size: 22px; font-weight: 700; color: var(--text); min-width: 0; }
.roas-out { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.demo-badge { display: inline-block; background: #fff3d6; color: #8a5a00; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; border: 1px solid #f0dca0; }
.notice { text-align: center; color: var(--muted); padding: 28px 16px; }
.notice .ne { font-size: 44px; }

@media (prefers-color-scheme: dark) {
  .tabbar { background: rgba(20,29,38,.92); }
  .demo-badge { background: #3a2e10; color: #f0c869; border-color: #55471e; }
  :root {
    --bg: #0e151d; --bg-2: #121b24; --surface: #17222d; --text: #eef4f8;
    --muted: #93a4b5; --faint: #6c7f90; --line: #253340; --brand-ink: #0a2a38;
    --shadow: 0 6px 20px rgba(0,0,0,.35); --shadow-lg: 0 18px 44px rgba(0,0,0,.55);
  }
  .job .svc { background: #14303c; }
}
