:root {
  --bg: var(--tg-theme-bg-color, #f4f4f7);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a1a);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2f80ed);
  --button: var(--tg-theme-button-color, #2f80ed);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --green: #2ecc71;
  --red: #eb5757;
  --orange: #f2994a;
  --radius: 14px;
}

* { 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, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.4;
}
#app { padding: 14px 14px 90px; max-width: 640px; margin: 0 auto; }
.hidden { display: none !important; }

h1 { font-size: 22px; margin: 6px 0 2px; }
h2 { font-size: 17px; margin: 18px 0 8px; }
.muted { color: var(--hint); font-size: 14px; }
.center { text-align: center; }

/* cards */
.card {
  background: var(--secondary-bg); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card .row { display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0; border-bottom: 1px solid rgba(128,128,128,.12); }
.card .row:last-child { border-bottom: none; }
.card .row .k { color: var(--hint); font-size: 14px; }
.card .row .v { font-weight: 600; text-align: right; }
.card .title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }

.big-num { font-size: 40px; font-weight: 800; line-height: 1; }

/* buttons */
.btn {
  display: block; width: 100%; border: none; cursor: pointer;
  padding: 14px; border-radius: var(--radius); font-size: 16px; font-weight: 600;
  background: var(--button); color: var(--button-text); margin-top: 10px;
}
.btn:active { opacity: .8; }
.btn.secondary { background: rgba(128,128,128,.14); color: var(--text); }
.btn.danger { background: var(--red); color: #fff; }
.btn.success { background: var(--green); color: #fff; }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; margin: 0; }
.btn:disabled { opacity: .5; }

/* status pills */
.pill { display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.pill.green { background: rgba(46,204,113,.15); color: #1e9e5a; }
.pill.red { background: rgba(235,87,87,.15); color: var(--red); }
.pill.orange { background: rgba(242,153,74,.18); color: #c97a2a; }

/* stat grid */
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat { background: var(--secondary-bg); border-radius: var(--radius);
  padding: 14px 10px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.stat .n { font-size: 30px; font-weight: 800; }
.stat .l { font-size: 12px; color: var(--hint); margin-top: 2px; }

/* list items */
.item { background: var(--secondary-bg); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.item .grow { flex: 1; min-width: 0; }
.item .lead { font-size: 24px; }
.item .t1 { font-weight: 600; }
.item .t2 { font-size: 13px; color: var(--hint); }
.item .free { font-weight: 700; color: #1e9e5a; white-space: nowrap; }

/* forms */
label { display: block; font-size: 13px; color: var(--hint); margin: 10px 0 4px; }
input, select {
  width: 100%; padding: 12px; border-radius: 12px; font-size: 16px;
  border: 1px solid rgba(128,128,128,.25); background: var(--bg); color: var(--text);
}
.weekdays { display: flex; gap: 6px; flex-wrap: wrap; }
.weekdays .wd { flex: 1; min-width: 40px; text-align: center; padding: 10px 0;
  border-radius: 10px; background: rgba(128,128,128,.14); font-weight: 600; cursor: pointer; }
.weekdays .wd.on { background: var(--button); color: var(--button-text); }

/* tabbar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--secondary-bg); border-top: 1px solid rgba(128,128,128,.18);
  padding-bottom: env(safe-area-inset-bottom); z-index: 50; }
.tabbar button { flex: 1; background: none; border: none; color: var(--hint);
  padding: 9px 0 8px; font-size: 11px; cursor: pointer; }
.tabbar button .ic { font-size: 22px; display: block; }
.tabbar button.active { color: var(--link); }

/* misc */
.loader { display: flex; justify-content: center; padding: 80px 0; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(128,128,128,.3);
  border-top-color: var(--link); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--hint); padding: 40px 16px; }
.empty .em { font-size: 44px; display: block; margin-bottom: 10px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; max-width: 90%; text-align: center; }
.divider { height: 1px; background: rgba(128,128,128,.15); margin: 14px 0; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: rgba(128,128,128,.16); }
