:root {
  --bg: var(--tg-theme-bg-color, #11131a);
  --bg2: var(--tg-theme-secondary-bg-color, #181b24);
  --text: var(--tg-theme-text-color, #f2f4fa);
  --hint: var(--tg-theme-hint-color, #8a93a6);
  --card: var(--tg-theme-section-bg-color, #1e222e);
  --accent: var(--tg-theme-button-color, #4f8cff);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --go: #2ec27e;
  --stop: #ff4d5e;
  --warn: #ffb020;
  --radius: 18px;
  --grad: linear-gradient(135deg, #6a5cff 0%, #4f8cff 55%, #2ec5ff 100%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  overscroll-behavior-y: contain;
}
body { padding-bottom: env(safe-area-inset-bottom, 0); }
.hidden { display: none !important; }

/* ---------- Hero ---------- */
.hero {
  position: sticky; top: 0; z-index: 20;
  background: var(--grad);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0) + 14px) 18px 18px;
  border-radius: 0 0 26px 26px;
  box-shadow: 0 8px 28px rgba(60, 80, 200, .28);
}
.hero__nav { display: flex; align-items: center; justify-content: space-between; }
.hero__arrow {
  background: rgba(255,255,255,.16); border: 0; color: #fff;
  width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1;
  display: grid; place-items: center; cursor: pointer; transition: transform .12s, background .2s;
}
.hero__arrow:active { transform: scale(.88); background: rgba(255,255,255,.28); }
.hero__month { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.hero__amount {
  font-size: 44px; font-weight: 800; letter-spacing: -1px;
  margin: 10px 0 0; text-align: center; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 14px rgba(0,0,0,.18);
}
.hero__sub { text-align: center; opacity: .82; font-size: 13px; margin-top: 2px; }
.hero__chips { display: flex; gap: 8px; margin-top: 16px; }
.chip {
  flex: 1; background: rgba(255,255,255,.15); border-radius: 14px;
  padding: 9px 4px; text-align: center; backdrop-filter: blur(4px);
}
.chip span { display: block; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.chip small { opacity: .8; font-size: 11px; }

/* ---------- Content ---------- */
.content { padding: 16px 14px 30px; max-width: 560px; margin: 0 auto; }

.livecard {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px;
}
.live__idle { display: flex; flex-direction: column; gap: 10px; }
.live__running { display: flex; align-items: center; gap: 14px; }
.live__pulse {
  width: 14px; height: 14px; border-radius: 50%; background: var(--stop);
  box-shadow: 0 0 0 0 rgba(255,77,94,.6); animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,77,94,.55); }
  70% { box-shadow: 0 0 0 14px rgba(255,77,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,77,94,0); }
}
.live__info { flex: 1; }
.live__label { color: var(--hint); font-size: 12px; }
.live__timer { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.live__earn { color: var(--go); font-weight: 700; font-size: 14px; }

.btn {
  border: 0; border-radius: 14px; padding: 14px 16px; font-size: 16px;
  font-weight: 700; cursor: pointer; color: #fff; transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn--go { background: var(--go); }
.btn--stop { background: var(--stop); padding: 12px 20px; }
.btn--danger { background: var(--stop); }
.btn--ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn.full { width: 100%; }

/* ---------- Calendar ---------- */
.calwrap { background: var(--card); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.cal__weekdays, .cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal__weekdays span { text-align: center; color: var(--hint); font-size: 11px; padding-bottom: 6px; }
.cal__cell {
  aspect-ratio: 1 / 1.08; border-radius: 11px; background: var(--bg2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer; position: relative; transition: transform .1s, background .2s;
  border: 1.5px solid transparent;
}
.cal__cell:active { transform: scale(.92); }
.cal__cell.empty { background: transparent; cursor: default; }
.cal__cell.worked { background: rgba(46,194,126,.16); color: var(--text); font-weight: 600; }
.cal__cell.worked .cal__amt { color: var(--go); }
.cal__cell.today { border-color: var(--accent); }
.cal__amt { font-size: 9px; line-height: 1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.cal__dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--go); }

.toolbar { display: flex; gap: 10px; }
.tool {
  flex: 1; background: var(--card); border: 0; color: var(--text);
  padding: 13px; border-radius: 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .1s;
}
.tool:active { transform: scale(.97); }
.hint { color: var(--hint); font-size: 12px; text-align: center; margin-top: 14px; }

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg2); border-radius: 22px 22px 0 0; padding: 8px 18px 26px;
  padding-bottom: calc(26px + env(safe-area-inset-bottom, 0));
  max-width: 560px; margin: 0 auto; max-height: 88vh; overflow-y: auto;
  animation: slideup .26s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -8px 34px rgba(0,0,0,.4);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__handle { width: 38px; height: 4px; border-radius: 2px; background: var(--hint); opacity: .4; margin: 6px auto 10px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet__head h3 { margin: 0; font-size: 18px; }
.sheet__close { background: var(--card); border: 0; color: var(--hint); width: 30px; height: 30px; border-radius: 50%; font-size: 15px; cursor: pointer; }

.daylist { margin: 6px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.day-item {
  background: var(--card); border-radius: 13px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
}
.day-item__time { font-weight: 600; }
.day-item__meta { color: var(--hint); font-size: 12px; margin-top: 2px; }
.day-item__amt { font-weight: 800; color: var(--go); }
.day-empty { color: var(--hint); text-align: center; padding: 18px 0; }

.field { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.field > span { font-size: 12px; color: var(--hint); }
.field input {
  background: var(--card); border: 1.5px solid transparent; border-radius: 12px;
  padding: 12px 14px; color: var(--text); font-size: 16px; width: 100%;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.calc-preview { text-align: center; font-size: 15px; color: var(--text); min-height: 22px; margin: 6px 0 2px; }
.calc-preview b { color: var(--go); }
.edit-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.note { color: var(--hint); font-size: 12px; line-height: 1.4; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #2b2f3c; color: #fff; padding: 12px 20px; border-radius: 30px;
  font-size: 14px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  animation: toastin .25s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
