/* Календарь: сетка месяца и недели, цветные отметки, легенда, панель дня, неделя на главной. */
:root {
  --k-ends: #b4631f; --k-freezes: #3b78ad; --k-trials: #8a6d1f; --k-events: #2f5d50; --k-mailings: #7b5aa6; --k-tasks: #6b7074;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --k-ends: #e2a27b; --k-freezes: #7fb4e0; --k-trials: #dcc27a; --k-events: #8cc3b2; --k-mailings: #bba2e0; --k-tasks: #a2a6a9;
  }
}
:root[data-theme="dark"] {
  --k-ends: #e2a27b; --k-freezes: #7fb4e0; --k-trials: #dcc27a; --k-events: #8cc3b2; --k-mailings: #bba2e0; --k-tasks: #a2a6a9;
}

.cdot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--k-tasks); }
.cdot.k-ends { background: var(--k-ends); }
.cdot.k-freezes { background: var(--k-freezes); }
.cdot.k-trials { background: var(--k-trials); }
.cdot.k-events { background: var(--k-events); }
.cdot.k-mailings { background: var(--k-mailings); }
.cdot.k-tasks { background: var(--k-tasks); }

/* верхняя полоса */
.cal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.cal-nav { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.cal-nav .icon-txt { padding: 4px 12px; font-size: var(--t-lg); line-height: 1.1; }
.cal-title { font-size: var(--t-xl); font-weight: 650; letter-spacing: -.01em; margin-left: var(--s2); }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.cal-filters { display: flex; flex-wrap: wrap; gap: var(--s2); }
.cal-filters select { max-width: 260px; padding: 5px 10px; font-size: var(--t-sm); }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); }
.legend-title { color: var(--muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-right: var(--s1); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 2px 10px; font-size: var(--t-sm); font-weight: 500; }
.legend-item:hover { background: var(--line-soft); filter: none; }
.legend-item[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; opacity: .65; }

/* раскладка: сетка слева, день справа */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--s4); align-items: start; }
.cal-main { min-width: 0; }
.cal-side { position: sticky; top: calc(var(--top-h) + var(--s4)); max-height: calc(100vh - var(--top-h) - var(--s5)); overflow-y: auto; }
.view:has(.cal-layout) { max-width: 1440px; }

/* сетка */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
  background: var(--line-soft); gap: 1px; box-shadow: var(--shadow-1); }
.cal-wd { background: var(--sunk); color: var(--muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding: var(--s2) var(--s3); }
.cal-cell { background: var(--surface); min-height: 112px; padding: var(--s2) var(--s2) var(--s2); cursor: pointer; display: grid; grid-template-rows: auto 1fr; gap: 4px; align-content: start; min-width: 0; }
.cal-cell:hover { background: var(--sunk); }
.cal-cell:focus-visible { outline-offset: -2px; }
.cal-cell.other { background: var(--sunk); }
.cal-cell.other .cal-num { color: var(--muted); opacity: .6; }
.cal-cell.other .cal-lines { opacity: .7; }
.cal-cell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { display: flex; align-items: baseline; gap: var(--s2); font-weight: 600; font-size: var(--t-md); }
.cal-num .cal-wdn { display: none; color: var(--muted); font-weight: 500; font-size: var(--t-sm); }
.cal-cell.today .cal-num > span:first-child { background: var(--accent); color: var(--accent-ink); border-radius: var(--r-pill); min-width: 24px; height: 24px; display: inline-grid; place-items: center; padding: 0 6px; }
.cal-lines { display: grid; gap: 3px; align-content: start; min-width: 0; }
.cline { display: flex; align-items: center; gap: 6px; font-size: var(--t-xs); line-height: 1.35; min-width: 0; }
.cline .ctext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cline.more, .cline.none { color: var(--muted); }
.cdots { display: none; gap: 4px; flex-wrap: wrap; }

/* неделя: колонки выше, строки шире */
.cal-grid.week .cal-cell { min-height: 220px; padding: var(--s2); }
.cal-grid.week .cal-wd { padding: var(--s2) var(--s3); }
.cal-grid.week .cline { font-size: var(--t-xs); align-items: flex-start; }
.cal-grid.week .cline .ctext { white-space: normal; overflow-wrap: anywhere; }
.cal-grid.week .cal-lines { gap: 6px; }

/* панель дня */
.day-card .card-head { align-items: center; flex-wrap: wrap; }
.day-body { display: grid; gap: var(--s4); padding: var(--s3) 0 var(--s2); }
.day-body > .empty { padding: var(--s4); }
.day-body > div:first-child:empty { display: none; }
.day-sec h3 { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); font-weight: 600; padding: 0 var(--s4) var(--s1); }
.day-sec h3 .count { color: var(--muted); font-weight: 500; }
.day-sec .list li { padding: 8px var(--s4); min-height: 44px; }
.day-sec .list li .who-cell small { white-space: normal; }
.pdot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.pdot.good { background: var(--good); }
.pdot.warn { background: var(--warn); }
.pdot.bad { background: var(--bad); }
.pdot.dim { background: transparent; border: 2px solid var(--muted); }
.ends-note { padding: 0 var(--s4); margin-top: calc(var(--s2) * -1); }
.plain, .ev-list { list-style: none; margin: 0; padding: 0; }
.plain li { display: grid; gap: 2px; padding: 8px var(--s4); border-top: 1px solid var(--line-soft); }
.plain li:first-child { border-top: 0; }
.plain li.click { cursor: pointer; }
.plain li.click:hover { background: var(--sunk); }
.ev-list li { padding: 8px var(--s4); border-top: 1px solid var(--line-soft); display: grid; gap: var(--s2); }
.ev-list li:first-child { border-top: 0; }
.ev-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.ev-time { color: var(--muted); font-size: var(--t-sm); }
.ev-form { margin: 0 var(--s4); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.form input[type="time"], .form input[type="date"], .form select, .form input[type="text"] { width: 100%; }

/* неделя на главной */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line-soft); border-radius: 0 0 var(--r-md) var(--r-md); overflow: hidden; }
.ws-day { background: var(--surface); padding: var(--s3); display: grid; gap: var(--s2); align-content: start; min-height: 120px; text-decoration: none; color: var(--ink); min-width: 0; }
.ws-day:hover { background: var(--sunk); }
.ws-head { display: flex; align-items: baseline; gap: var(--s2); }
.ws-wd { color: var(--muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.ws-num { font-weight: 650; font-size: var(--t-lg); }
.ws-day.today .ws-num { background: var(--accent); color: var(--accent-ink); border-radius: var(--r-pill); min-width: 26px; height: 26px; display: inline-grid; place-items: center; padding: 0 6px; font-size: var(--t-md); }
.ws-day .cline { align-items: flex-start; }
.ws-day .cline .ctext { white-space: normal; overflow-wrap: anywhere; }
.link-more { color: var(--accent); font-size: var(--t-sm); text-decoration: none; }
.link-more:hover { text-decoration: underline; }
.soon-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .cal-side { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 760px) {
  .cal-title { font-size: var(--t-lg); margin-left: 0; }
  .cal-wd { padding: var(--s2) 0; text-align: center; font-size: 10px; letter-spacing: 0; }
  .cal-grid:not(.week) .cal-cell { min-height: 56px; padding: 6px 2px; justify-items: center; text-align: center; }
  .cal-grid:not(.week) .cal-lines { display: none; }
  .cal-grid:not(.week) .cdots { display: flex; justify-content: center; gap: 3px; }
  .cal-grid:not(.week) .cdot { width: 7px; height: 7px; }
  .cal-grid:not(.week) .cal-num { justify-content: center; font-size: var(--t-sm); }
  .cal-grid.week { display: block; }
  .cal-grid.week .cal-wd { display: none; }
  .cal-grid.week .cal-cell { min-height: 0; grid-template-columns: 74px minmax(0, 1fr); grid-template-rows: none; gap: var(--s3); border-top: 1px solid var(--line-soft); }
  .cal-grid.week .cal-num { flex-direction: column; gap: 0; align-items: flex-start; }
  .cal-grid.week .cal-num .cal-wdn { display: block; }
  .week-strip { display: block; }
  .ws-day { grid-template-columns: 74px minmax(0, 1fr); min-height: 0; border-top: 1px solid var(--line-soft); }
  .ws-head { flex-direction: column; gap: 0; align-items: flex-start; }
  .soon-grid.two { grid-template-columns: minmax(0, 1fr); }
  .form-row { grid-template-columns: minmax(0, 1fr); }
}
