/* ==========================================================================
   Планировщик года. Тёмная плотная тема — смотреть каждый день с телефона
   и с компа, поэтому приоритет читаемости и размера тач-целей.
   ========================================================================== */

:root {
  --bg:        #0b0d12;
  --bg-1:      #12151d;
  --bg-2:      #181c26;
  --bg-3:      #212736;
  --line:      #2a3143;
  --line-soft: #1e2432;

  --fg:        #e8ecf5;
  --fg-dim:    #97a1b8;
  --fg-faint:  #626d85;

  --accent:    #5b8cff;
  --accent-2:  #7c5bff;

  --p0:        #ff4d5e;
  --p1:        #ff9f2e;
  --p2:        #5b8cff;
  --p3:        #5a6479;

  --ok:        #2ecc8f;
  --warn:      #ffcc4d;
  --dead:      #4a5163;

  --radius:    12px;
  --radius-sm: 8px;
  --gap:       12px;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Inter,
          system-ui, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

/* Собственный display у .gate/.sheet сильнее браузерного [hidden]{display:none},
   поэтому скрытие приходится форсировать явно. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }

/* ───────────────────────────── парольный гейт ───────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(1200px 800px at 50% -10%, #1a2138, var(--bg) 60%);
  display: grid; place-items: center; padding: 24px;
}
.gate__box {
  width: min(380px, 100%);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.gate__logo { font-size: 40px; margin-bottom: 8px; }
.gate__box h1 { font-size: 22px; }
.gate__sub { color: var(--fg-dim); font-size: 13px; margin: 0 0 22px; }
.gate__box input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); outline: none;
}
.gate__box input:focus { border-color: var(--accent); }
.gate__box .btn { width: 100%; justify-content: center; }
.gate__err {
  margin-top: 12px; padding: 8px 10px; font-size: 13px;
  background: rgba(255,77,94,.12); color: #ff8b96;
  border: 1px solid rgba(255,77,94,.3); border-radius: var(--radius-sm);
}
.gate__offline {
  margin-top: 18px; background: none; border: 0;
  color: var(--fg-faint); font-size: 12px; cursor: pointer;
  text-decoration: underline;
}

/* ──────────────────────────────── шапка ─────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11,13,18,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top__row {
  display: flex; align-items: center; gap: var(--gap);
  padding: 10px 16px;
}
.top__row--sub {
  padding-top: 0; padding-bottom: 10px;
  overflow-x: auto; scrollbar-width: none;
}
.top__row--sub::-webkit-scrollbar { display: none; }

.brand { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand span { display: none; }
@media (min-width: 900px) { .brand span { display: inline; } }

.profile-badge {
  padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 650;
  background: rgba(124,91,255,.16); border: 1px solid rgba(124,91,255,.35);
  color: #b3a0ff; white-space: nowrap;
}
.profile-badge[data-profile="main"] {
  background: rgba(91,140,255,.16); border-color: rgba(91,140,255,.35); color: #9bb8ff;
}
.profile-badge[data-profile="local"] {
  background: var(--bg-3); border-color: var(--line); color: var(--fg-faint);
}

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; padding: 7px 12px; border-radius: 999px;
  color: var(--fg-dim); cursor: pointer; white-space: nowrap; font-size: 14px;
}
.tab:hover { color: var(--fg); background: var(--bg-2); }
.tab.is-active { background: var(--accent); color: #fff; font-weight: 600; }

.top__right { display: flex; align-items: center; gap: 8px; }
.search {
  width: 130px; padding: 7px 12px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 999px; outline: none;
  transition: width .18s ease;
}
.search:focus { width: 220px; border-color: var(--accent); }
@media (max-width: 700px) { .search { width: 96px; } .search:focus { width: 150px; } }

.sync { color: var(--fg-faint); font-size: 11px; }
.sync.is-ok      { color: var(--ok); }
.sync.is-busy    { color: var(--warn); }
.sync.is-err     { color: var(--p0); }
.sync.is-offline { color: var(--fg-faint); }

.datepick {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 10px; outline: none;
  color-scheme: dark;
}
.select {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 10px; outline: none;
}
.spacer { flex: 1; min-width: 8px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--fg-dim); font-size: 13px; white-space: nowrap; cursor: pointer;
}
.toggle input { accent-color: var(--accent); }

/* ──────────────────────────────── кнопки ────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line);
  cursor: pointer; white-space: nowrap; transition: .12s;
}
.btn:hover { background: var(--bg-3); border-color: #38415a; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn--primary:hover { background: #4a7cf0; }
.btn--ghost { background: none; }
.btn--danger { background: rgba(255,77,94,.12); border-color: rgba(255,77,94,.35); color: #ff8b96; }
.btn--sm { padding: 5px 10px; font-size: 13px; }

/* ─────────────────────────────── контент ────────────────────────────── */
.main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 96px; }

.dayhead { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.dayhead h2 { font-size: 24px; letter-spacing: -.02em; margin: 0; }
.dayhead .wd { color: var(--fg-dim); }
.dayhead .badge-today {
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
}
.daysub { color: var(--fg-faint); font-size: 13px; margin-bottom: 18px; }

.group { margin-bottom: 26px; }
.group__head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--fg-faint);
}
.group__head::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }
.group--p0 .group__head { color: var(--p0); }
.group--p1 .group__head { color: var(--p1); }

/* ───────────────────────────── карточка дела ────────────────────────── */
.card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--p3);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
  transition: .12s;
}
.card:hover { border-color: var(--line); background: var(--bg-2); }
.card--p0 { border-left-color: var(--p0); }
.card--p1 { border-left-color: var(--p1); }
.card--p2 { border-left-color: var(--p2); }
.card.is-done { opacity: .42; }
.card.is-done .card__title { text-decoration: line-through; }
.card.is-skipped { opacity: .38; }
.card.is-skipped .card__title { text-decoration: line-through; color: var(--fg-faint); }
.card.is-cancelled {
  opacity: .5; border-left-color: var(--dead);
  background: repeating-linear-gradient(45deg, var(--bg-1), var(--bg-1) 8px, #101319 8px, #101319 16px);
}

.check {
  flex: 0 0 auto; width: 24px; height: 24px; margin-top: 2px;
  border: 2px solid var(--line); border-radius: 7px;
  background: none; cursor: pointer; color: transparent;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  transition: .12s;
}
.check:hover { border-color: var(--accent); }
.check.is-done { background: var(--ok); border-color: var(--ok); color: #06210f; }
.check.is-skipped { background: var(--bg-3); border-color: var(--fg-faint); color: var(--fg-faint); }

.card__body { flex: 1; min-width: 0; }
.card__title { font-weight: 550; cursor: pointer; }
.card__title:hover { color: var(--accent); }
.card__meta {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px;
  font-size: 12px; color: var(--fg-dim);
}
.card__hint { margin-top: 6px; font-size: 13px; color: var(--fg-dim); }
.card__actions { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg-dim);
  white-space: nowrap;
}
.chip--kind-deadline { background: rgba(255,77,94,.14); border-color: rgba(255,77,94,.32); color: #ff9aa4; }
.chip--kind-contest  { background: rgba(91,140,255,.14); border-color: rgba(91,140,255,.32); color: #9bb8ff; }
.chip--kind-prep     { background: rgba(124,91,255,.12); border-color: rgba(124,91,255,.28); color: #b3a0ff; }
.chip--kind-reminder { background: rgba(255,204,77,.11); border-color: rgba(255,204,77,.26); color: #ffd97a; }
.chip--travel { background: rgba(46,204,143,.14); border-color: rgba(46,204,143,.32); color: #6fe3b6; }
.chip--money  { background: rgba(255,204,77,.12); border-color: rgba(255,204,77,.28); color: #ffd97a; }
.chip--est    { border-style: dashed; color: var(--fg-faint); }
.chip--region { background: rgba(124,91,255,.14); border-color: rgba(124,91,255,.3); color: #b3a0ff; }

.outcome { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.outcome__btn {
  padding: 4px 10px; font-size: 12px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line); cursor: pointer;
  color: var(--fg-dim);
}
.outcome__btn:hover { border-color: var(--accent); color: var(--fg); }
.outcome__btn.is-on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.outcome__btn.is-on[data-outcome="failed"] { background: var(--p0); border-color: var(--p0); }
.outcome__btn.is-on[data-outcome="passed"] { background: var(--ok); border-color: var(--ok); color: #06210f; }

.cancelled-note {
  margin-top: 8px; font-size: 12px; color: var(--p0);
  background: rgba(255,77,94,.08); border: 1px dashed rgba(255,77,94,.3);
  border-radius: var(--radius-sm); padding: 6px 9px;
}

.empty { text-align: center; padding: 60px 20px; color: var(--fg-faint); }
.empty__icon { font-size: 40px; margin-bottom: 12px; }

/* ────────────────────────────── неделя ──────────────────────────────── */
.week { display: grid; gap: 10px; }
@media (min-width: 900px) { .week { grid-template-columns: repeat(7, 1fr); } }
.week__day {
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 10px; min-height: 90px;
}
.week__day.is-today { border-color: var(--accent); }
.week__day h4 { font-size: 12px; color: var(--fg-dim); margin-bottom: 8px; }
.week__day.is-today h4 { color: var(--accent); }
.week__item {
  font-size: 12px; padding: 4px 6px; border-radius: 6px; margin-bottom: 4px;
  background: var(--bg-2); border-left: 2px solid var(--p3); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.week__item--p0 { border-left-color: var(--p0); }
.week__item--p1 { border-left-color: var(--p1); }
.week__item--p2 { border-left-color: var(--p2); }
.week__item.is-done { opacity: .4; text-decoration: line-through; }

/* ───────────────────────────── календарь ────────────────────────────── */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__wd { text-align: center; font-size: 11px; color: var(--fg-faint); padding: 6px 0; text-transform: uppercase; }
.cal__cell {
  aspect-ratio: 1; background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 5px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; transition: .12s;
}
.cal__cell:hover { border-color: var(--accent); }
.cal__cell.is-out { opacity: .25; pointer-events: none; }
.cal__cell.is-today { border-color: var(--accent); background: rgba(91,140,255,.08); }
.cal__num { font-size: 12px; color: var(--fg-dim); }
.cal__dots { display: flex; flex-wrap: wrap; gap: 2px; }
.cal__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--p3); }
.cal__dot--p0 { background: var(--p0); }
.cal__dot--p1 { background: var(--p1); }
.cal__dot--p2 { background: var(--p2); }

/* ─────────────────────────── каталог событий ────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.ev {
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  cursor: pointer; transition: .12s;
}
.ev:hover { border-color: var(--accent); background: var(--bg-2); }
.ev__top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.ev__name { font-weight: 600; }
.ev__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ev__stages { margin-top: 10px; font-size: 12px; color: var(--fg-dim); }
.ev__stage { display: flex; gap: 8px; padding: 2px 0; }
.ev__stage b { color: var(--fg); font-weight: 500; }
.ev.is-dead { opacity: .45; }

.stars { color: var(--warn); font-size: 12px; letter-spacing: 1px; }

/* ────────────────────────────── прогресс ────────────────────────────── */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 26px; }
.stat {
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 16px;
}
.stat__num { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.stat__lbl { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }
.stat--good .stat__num { color: var(--ok); }
.stat--warn .stat__num { color: var(--warn); }
.stat--bad  .stat__num { color: var(--p0); }

.bar { height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar__fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }

.rows { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center;
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.row__bar { grid-column: 1 / -1; }

/* ─────────────────────────────── шторка ─────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4,6,10,.72); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  overflow-y: auto;
}
.sheet__box {
  width: min(440px, 100%); background: var(--bg-1);
  border: 1px solid var(--line); border-radius: 18px; padding: 24px;
  display: grid; gap: 10px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.sheet__box--wide { width: min(720px, 100%); }
.sheet__box h3 { margin: 10px 0 2px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--fg-faint); }
.sheet__meta { font-size: 12px; color: var(--fg-faint); font-family: var(--mono); }

.detail__title { font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.detail__grid {
  display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px;
  font-size: 14px; margin: 14px 0;
}
.detail__grid dt { color: var(--fg-faint); }
.detail__grid dd { margin: 0; }
.detail__stages { display: grid; gap: 6px; margin-top: 6px; }
.detail__stage {
  display: grid; grid-template-columns: 108px 1fr; gap: 10px;
  padding: 9px 11px; background: var(--bg-2); border-radius: var(--radius-sm);
  border-left: 3px solid var(--line); font-size: 13px;
}
.detail__stage.is-cancelled { opacity: .45; border-left-color: var(--dead); }
.detail__stage.is-passed { border-left-color: var(--ok); }
.detail__stage.is-failed { border-left-color: var(--p0); }
.detail__date { font-family: var(--mono); font-size: 12px; color: var(--fg-dim); }

.note {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px;
  color: var(--fg-dim);
}

@media (max-width: 640px) {
  .main { padding: 14px 12px 90px; }
  .detail__grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail__grid dt { margin-top: 8px; }
  .detail__stage { grid-template-columns: 1fr; }
}
