/* ───────────── Токены ───────────── */
:root {
  --bg: #0B0C10;
  --surface: #15171D;
  --surface-2: #1D2028;
  --surface-3: #272B35;
  --border: rgba(255, 255, 255, 0.06);
  --text: #F3F5F7;
  --text-2: #98A0AD;
  --text-3: #5D6470;
  --accent: #2FBF85;
  --accent-2: #5FE0AA;
  --accent-ink: #04140D;
  --accent-soft: rgba(47, 191, 133, 0.15);
  --red: #FF5C5C;
  --red-soft: rgba(255, 92, 92, 0.14);
  --warn: #FFB224;
  --warn-soft: rgba(255, 178, 36, 0.14);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --glass: rgba(13, 14, 19, 0.82);
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --tabbar-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme="light"] {
  --bg: #F2F4F6;
  --surface: #FFFFFF;
  --surface-2: #F1F3F6;
  --surface-3: #E5E8ED;
  --border: rgba(10, 20, 30, 0.07);
  --text: #0E1116;
  --text-2: #646C78;
  --text-3: #A4AAB4;
  --accent: #14A86C;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(20, 168, 108, 0.12);
  --red: #EE4545;
  --red-soft: rgba(238, 69, 69, 0.1);
  --warn-soft: rgba(255, 178, 36, 0.16);
  --shadow: 0 10px 28px rgba(20, 30, 50, 0.08);
  --glass: rgba(250, 251, 253, 0.86);
}

/* ───────────── База ───────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
h1, h2 { margin: 0; letter-spacing: -0.02em; }
.ic { flex: none; display: block; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; }
#screen { padding: 14px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px); }
.screen-in { animation: rise 0.35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ───────────── Шапка ───────────── */
.top { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.top h1 { font-size: 26px; flex: 1; min-width: 0; }
.top h1 small { font-size: 15px; color: var(--text-3); font-weight: 600; margin-left: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--surface); color: var(--text-2); flex: none;
}
.icon-btn:active { transform: scale(0.94); }

/* ───────────── Счётчики ───────────── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border-radius: var(--r-md); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; letter-spacing: -0.02em; }
.stat span { font-size: 12px; color: var(--text-2); }
.stat.hero { background: linear-gradient(135deg, #2FBF85, #11845A); color: #fff; }
.stat.hero span { color: rgba(255, 255, 255, 0.8); }

/* ───────────── Карточки и поля ───────────── */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 14px; }
.form { display: grid; gap: 10px; }
.label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; margin: 6px 2px -2px; }
.field {
  display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: var(--r-sm);
  padding: 0 12px; min-height: 50px; color: var(--text-3); border: 1.5px solid transparent; transition: border-color 0.15s;
}
.field:focus-within { border-color: var(--accent); color: var(--accent); }
.field input, .field textarea { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); padding: 13px 0; font-size: 16px; }
.field textarea { resize: none; min-height: 64px; line-height: 1.4; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field .mini {
  font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
  padding: 6px 10px; border-radius: 9px; flex: none;
}
.field .clear { color: var(--text-3); padding: 6px; }
.hint { font-size: 13px; color: var(--text-2); padding: 0 4px; }
.hint.ok { color: var(--accent); }

.dup {
  display: flex; gap: 10px; align-items: center; background: var(--warn-soft); color: var(--text);
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 14px; text-align: left; width: 100%;
}
.dup .ic { color: var(--warn); }
.dup span { flex: 1; min-width: 0; }
.dup small { display: block; color: var(--text-2); font-size: 12px; }

/* ───────────── Кнопки-«чипы» и переключатели ───────────── */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none; white-space: nowrap;
  padding: 8px 13px; border-radius: 11px; background: var(--surface-2); color: var(--text);
  font-size: 14px; font-weight: 500; border: 1.5px solid transparent;
}
.card .chip { background: var(--surface-2); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.ghost { color: var(--text-2); background: transparent; border: 1.5px dashed var(--surface-3); }
.chip .n { color: var(--text-3); font-size: 12px; font-weight: 600; }
.chip.on .n { color: inherit; opacity: 0.75; }
.chip i.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
:not(.card) > .chips .chip { background: var(--surface); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-sm); }
.seg button { padding: 10px 6px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }
.seg button.on.yes { color: var(--accent); }
.seg button.on.no { color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px;
  border-radius: var(--r-md); padding: 0 18px; font-weight: 700; font-size: 16px;
  background: var(--surface-2); color: var(--text);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 40px; font-size: 14px; border-radius: 12px; padding: 0 14px; }

/* ───────────── Поиск и список ───────────── */
.search { margin-bottom: 10px; background: var(--surface); }
.filters { display: grid; gap: 8px; margin-bottom: 14px; }
.day-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 16px 4px 8px; }
.list { padding: 4px; }
.lead {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px; border-radius: 14px;
}
.lead:active { background: var(--surface-2); }
.lead + .lead { box-shadow: 0 -1px 0 var(--border); }
.av {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none;
  font-weight: 800; font-size: 17px; color: #fff; background: var(--c, var(--accent));
}
.av.lg { width: 56px; height: 56px; border-radius: 17px; font-size: 23px; }
.lead-main { flex: 1; min-width: 0; }
.lead-main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-main small { display: block; color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  flex: none; font-size: 12px; font-weight: 700; padding: 5px 9px; border-radius: 9px;
  color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent);
}
.wa-dot { color: #25D366; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.more { text-align: center; color: var(--text-3); font-size: 13px; padding: 10px; }

.team-stats { display: grid; gap: 6px; margin-top: 10px; font-size: 14px; }
.team-stats div { display: flex; justify-content: space-between; color: var(--text-2); }
.team-stats b { color: var(--text); }

/* ───────────── Нижняя панель ───────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr; padding: 6px 24px calc(6px + var(--safe-bottom));
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
}
.tab { display: grid; justify-items: center; gap: 3px; padding: 6px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.tab.on { color: var(--accent); }
.tab .badge { position: absolute; }

/* ───────────── Шторка ───────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); animation: fade 0.25s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 26px 26px 0 0; padding: 8px 16px calc(20px + var(--safe-bottom));
  animation: up 0.35s var(--ease);
}
.sheet.closing { animation: down 0.22s ease-in forwards; }
.sheet-wrap.closing .sheet-bg { animation: fade 0.22s reverse forwards; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-head .t { flex: 1; min-width: 0; }
.sheet-head h2 { font-size: 21px; overflow-wrap: anywhere; }
.sheet-head small { display: block; color: var(--text-2); font-size: 13px; margin-top: 2px; }
.acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.act {
  display: grid; justify-items: center; gap: 5px; padding: 12px 6px; border-radius: var(--r-md);
  background: var(--surface); font-size: 13px; font-weight: 600;
}
.act .ic { color: var(--accent); }
.act.wa .ic { color: #25D366; }
.act:disabled { opacity: 0.35; }
.sheet .stack { display: grid; gap: 10px; }
.sheet .foot { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 16px; }
.meta { color: var(--text-3); font-size: 12px; text-align: center; margin-top: 12px; }

.group { background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px; }
.row + .row { box-shadow: 0 -1px 0 var(--border); }
.row .l { flex: 1; min-width: 0; }
.row .l small { display: block; color: var(--text-2); font-size: 12px; }
.row .v { color: var(--text-2); font-size: 14px; }
.row input.inline { width: 80px; text-align: right; border: 0; outline: 0; background: var(--surface-2); border-radius: 9px; padding: 7px 9px; }
.group-note { font-size: 12px; color: var(--text-2); padding: 6px 6px 0; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--surface-3); position: relative; flex: none; transition: background 0.2s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s var(--ease); }
.switch.on { background: var(--accent); }
.switch.on i { transform: translateX(18px); }
.ok-dot { color: var(--accent); }
.bad { color: var(--red); }

/* ───────────── Уведомление ───────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: 0.25s var(--ease);
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px;
  padding: 11px 16px; border-radius: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); color: #fff; }

/* ───────────── Заставка ───────────── */
#splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); transition: opacity 0.3s; }
#splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { width: 64px; height: 64px; border-radius: 18px; background: url(/favicon.svg) center / cover; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.92); opacity: 0.7; } }

.blocked { min-height: 70dvh; display: grid; place-items: center; text-align: center; padding: 20px; }
.blocked .card { max-width: 340px; padding: 24px; }
.blocked b { display: block; font-size: 19px; margin: 12px 0 6px; }
.blocked p { color: var(--text-2); margin: 0; }

/* ───────────── Мелочи ───────────── */
.icon-btn { position: relative; }
.badge-dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--surface); }
.row-title { display: flex; align-items: center; justify-content: space-between; }
.link { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 13px; font-weight: 600; }
.day-title .n { color: var(--text-3); font-weight: 600; margin-left: 4px; }
.center-hint { text-align: center; margin: 18px 10px 0; line-height: 1.5; }
a.act { color: inherit; text-decoration: none; }
button.row { width: 100%; text-align: left; }
button.row .ic { color: var(--text-3); }
.lock { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat b { font-variant-numeric: tabular-nums; }
