:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --sec: var(--tg-theme-secondary-bg-color, #efeff4);
  --header: var(--tg-theme-header-bg-color, var(--bg));
  --accent: var(--tg-theme-accent-text-color, var(--btn));
  --section: var(--tg-theme-section-bg-color, #fff);
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --sep: color-mix(in srgb, var(--hint) 22%, transparent);
  --travel: #c47b17;
  --rest: #7b61c4;
  --tab-h: 56px;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--sec); color: var(--text); font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
#app { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom, 0px); }
body.has-tabs #app { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); }

.top {
  padding: calc(10px + var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 0px))) 16px 12px;
  background: var(--sec);
  max-width: 520px;
}
.top h1 { margin: 0; font-size: 28px; font-weight: 720; letter-spacing: -0.03em; }
.top .sub { color: var(--hint); font-size: 14px; margin-top: 4px; }

.wrap { padding: 0 16px 24px; max-width: 520px; }
.group {
  background: var(--section);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 48px;
  border-bottom: 0.5px solid var(--sep);
}
.row:last-child { border-bottom: 0; }
.row.tap { cursor: pointer; }
.row .lbl { flex: 1; }
.row .lbl small { display: block; color: var(--hint); font-size: 13px; font-weight: 400; }
.row .val { color: var(--hint); font-size: 15px; }
.chev { color: var(--hint); font-size: 18px; line-height: 1; }
.head-row { padding: 12px 16px 6px; color: var(--hint); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }

.hero {
  background: var(--section);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  margin-bottom: 16px;
  text-align: center;
}
.hero .st { font-size: 13px; color: var(--hint); text-transform: uppercase; letter-spacing: 0.06em; }
.hero .big { font-size: 34px; font-weight: 720; letter-spacing: -0.04em; margin: 6px 0 4px; }
.hero .big em { font-style: normal; color: var(--accent); margin-right: 0.2em; }
.ring-wrap { width: 112px; height: 112px; margin: 12px auto 4px; position: relative; }
.ring-wrap svg { width: 112px; height: 112px; transform: rotate(-90deg); }
.ring-wrap .num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; transform: none;
}
.ring-wrap .num b { font-size: 28px; font-weight: 720; }
.ring-wrap .num span { font-size: 11px; color: var(--hint); }

.money { font-variant-numeric: tabular-nums; }
.muted { color: var(--hint); }
.danger { color: var(--danger); }
.accent { color: var(--accent); }

.cal-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin-bottom: 8px; }
.cal-nav b { font-size: 18px; text-align: center; }
.cal-nav button, .icon-btn {
  background: var(--section); color: var(--accent); border: 0; border-radius: 10px;
  padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer;
}
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.week span { text-align: center; font-size: 11px; color: var(--hint); padding: 4px 0; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.grid.paint-on { touch-action: none; }
.cell {
  aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 14px; font-weight: 600;
  background: transparent; border: 0; color: var(--text); cursor: pointer; padding: 0;
}
.cell.off { color: var(--hint); opacity: 0.45; }
.cell.today { outline: 1.5px solid var(--accent); }
.cell .dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 2px; }
.cell.t-w { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.cell.t-h { background: color-mix(in srgb, var(--hint) 12%, transparent); }
.cell.t-to, .cell.t-from { background: color-mix(in srgb, var(--travel) 22%, transparent); }
.cell.t-r { background: color-mix(in srgb, var(--rest) 20%, transparent); }
.cell.t-s { background: color-mix(in srgb, var(--danger) 16%, transparent); }
.cell.t-v { background: color-mix(in srgb, var(--link) 16%, transparent); }
.cell .dot.t-w { background: var(--accent); }
.cell .dot.t-h { background: var(--hint); }
.cell .dot.t-to, .cell .dot.t-from { background: var(--travel); }
.cell .dot.t-r { background: var(--rest); }
.cell .dot.t-s { background: var(--danger); }
.cell .dot.t-v { background: var(--link); }

.brush { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.brush::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 0; background: var(--section); color: var(--text);
  border-radius: 20px; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.chip.on { background: var(--btn); color: var(--btn-text); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--header); border-top: 0.5px solid var(--sep);
  display: grid; grid-template-columns: repeat(4, 1fr); z-index: 5;
}
.tabs button {
  border: 0; background: transparent; color: var(--hint); font: inherit;
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.tabs button.on { color: var(--accent); }

.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20;
  display: flex; align-items: flex-end;
}
.sheet .box {
  background: var(--section); width: 100%; border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: 88dvh; overflow: auto;
}
.grab { width: 36px; height: 4px; background: var(--sep); border-radius: 4px; margin: 4px auto 12px; }
.sheet h2 { margin: 0 0 12px; font-size: 20px; }

input, select, textarea {
  width: 100%; border: 0; background: var(--sec); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font: inherit;
}
textarea { min-height: 88px; resize: vertical; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 6px; }
.btn {
  display: block; width: 100%; border: 0; border-radius: 12px;
  padding: 14px; font: inherit; font-weight: 650; cursor: pointer;
  background: var(--btn); color: var(--btn-text); margin-top: 8px;
}
.btn.ghost { background: var(--sec); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.statline { display: flex; justify-content: space-between; padding: 6px 0; font-size: 15px; }
.statline span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }

.wiz { padding: 24px 16px 40px; max-width: 520px; }
.wiz h1 { font-size: 28px; margin: 0 0 8px; letter-spacing: -0.03em; }
.wiz p { color: var(--hint); margin: 0 0 20px; }
.preset { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.preset button, .choice {
  background: var(--section); border: 0; border-radius: 14px; padding: 16px;
  font: inherit; font-weight: 650; color: var(--text); cursor: pointer; text-align: left;
}
.preset button.on, .choice.on { outline: 2px solid var(--accent); }

.page { min-height: 100dvh; background: var(--sec); }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom, 0px));
  background: #1c1c1e; color: #fff; text-align: center; padding: 12px; border-radius: 12px;
  z-index: 30; font-size: 14px;
}

.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12px; color: var(--hint); margin: 8px 0 0; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.check { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--hint); flex: 0 0 22px; }
.check.on { background: var(--btn); border-color: var(--btn); }
.done .lbl { color: var(--hint); text-decoration: line-through; }

.warn { background: color-mix(in srgb, var(--danger) 10%, var(--section)); }
