[hidden] { display: none !important; }
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f5);
  --text: var(--tg-theme-text-color, #111418);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --link: var(--tg-theme-link-color, #2563eb);
  --btn: var(--tg-theme-button-color, #1f6feb);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --sep: color-mix(in srgb, var(--hint) 25%, transparent);
  --ok: #16a34a;
  --bad: #dc2626;
  --warn: #d97706;
  --info: #2563eb;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--sep); }
#title { font-weight: 600; font-size: 17px; }
.titles { min-width: 0; flex: 1; }
.titles div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--hint); font-size: 13px; }
.center { text-align: center; padding: 32px 16px; }
main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.icon-btn { border: 0; background: none; color: var(--link); font-size: 28px; line-height: 1; padding: 0 6px 2px 0; cursor: pointer; }

nav#tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--bg);
  border-top: 1px solid var(--sep); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav#tabs button { flex: 1; border: 0; background: none; color: var(--hint); padding: 8px 2px 10px;
  font-size: 12px; cursor: pointer; position: relative; }
nav#tabs button .ic { display: block; font-size: 20px; }
nav#tabs button.active { color: var(--btn); font-weight: 600; }
.badge { position: absolute; top: 4px; left: 55%; background: var(--bad); color: #fff; border-radius: 9px;
  font-size: 11px; padding: 0 5px; min-width: 18px; }

.card { background: var(--bg); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.card.tap { cursor: pointer; }
.row { display: flex; align-items: center; gap: 8px; }
.row .grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 16px 4px 8px; }
.name { font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg2); color: var(--hint); }
.chip.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.chip.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.chip.info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }

.list .item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--sep); }
.list .item:last-child { border-bottom: 0; }

.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 8px; }
.seg button { border: 1px solid var(--sep); background: var(--bg); color: var(--text); border-radius: 8px;
  padding: 7px 2px; font-size: 12px; cursor: pointer; }
.seg button.on.KELDI { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg button.on.KELMADI { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg button.on.SABABLI { background: var(--info); border-color: var(--info); color: #fff; }
.seg button.on.KECHIKDI { background: var(--warn); border-color: var(--warn); color: #fff; }
.seg button:disabled { opacity: .55; }

.btn { display: block; width: 100%; border: 0; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 600;
  background: var(--btn); color: var(--btn-text); cursor: pointer; margin-top: 8px; }
.btn.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--sep); }
.btn.danger { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.btn:disabled { opacity: .6; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.small-btn { border: 0; background: var(--bg2); color: var(--link); border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }

label.f { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--hint); }
input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--sep);
  background: var(--bg); color: var(--text); font: inherit; }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.check input { width: auto; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.days label { text-align: center; padding: 8px 0; border-radius: 8px; border: 1px solid var(--sep); background: var(--bg); font-size: 12px; cursor: pointer; }
.days input { display: none; }
.days label.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: var(--radius); padding: 12px; }
.stat .v { font-size: 22px; font-weight: 700; }

.datebar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.datebar b { font-size: 16px; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20;
  background: #111; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; text-align: center; }
#toast.err { background: var(--bad); }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; }
#modal .sheet { background: var(--bg); width: 100%; max-height: 85vh; overflow: auto; border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.linkbox { word-break: break-all; font-size: 13px; background: var(--bg2); padding: 8px; border-radius: 8px; margin-top: 4px; }
.sticky-actions { position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); padding-top: 8px;
  background: linear-gradient(transparent, var(--bg2) 30%); }
