/* ==========================================================================
   ЗАНЯТИЯ v2 — планировщик, неделя, список и печатное расписание
   ========================================================================== */

.tpx { display: flex; flex-direction: column; gap: 14px; }
.tpx-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.tpx-head__title { flex: 1; min-width: 250px; }
.tpx-head__title h2 { margin: 0; font-size: 1.42rem; font-weight: 760; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.tpx-head__title h2 i { color: var(--c-brand); }
.tpx-head__title p { margin: 4px 0 0; color: var(--c-muted); font-size: .84rem; }
.tpx-head__actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.tpx-btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 12px;
  font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.tpx-btn--primary { background: var(--c-brand); color: #fff; box-shadow: 0 4px 12px -6px rgba(37, 99, 235, .7); }
.tpx-btn--primary:hover { background: var(--c-brand-2, #1d4ed8); }
.tpx-btn--soft { background: var(--c-brand-soft); color: var(--c-brand); }
.tpx-btn--soft:hover { background: rgba(37, 99, 235, .16); }
.tpx-btn--ghost { background: var(--c-surface); color: var(--c-text-2); border-color: var(--c-border); }
.tpx-btn--ghost:hover { background: var(--c-surface-2); color: var(--c-text); }

.tpx-command {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: var(--c-shadow-sm);
}
.tpx-select { display: flex; flex-direction: column; gap: 4px; min-width: 260px; }
.tpx-select span { font-size: .66rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); }
.tpx-select select {
  height: 38px; padding: 0 32px 0 11px;
  border: 1px solid var(--c-border); border-radius: 10px;
  background: var(--c-surface); color: var(--c-text); font: inherit; font-size: .84rem;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c8798' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.tpx-select select:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--c-ring); }
.tpx-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; flex: 1; min-width: 420px; }
.tpx-stat { display: flex; align-items: center; gap: 8px; padding: 3px 8px; min-width: 0; }
.tpx-stat__icon { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--c-brand-soft); color: var(--c-brand); font-size: .76rem; }
.tpx-stat--warning .tpx-stat__icon { background: rgba(217, 119, 6, .12); color: #d97706; }
.tpx-stat--success .tpx-stat__icon { background: rgba(5, 150, 105, .12); color: #059669; }
.tpx-stat b { display: block; font-size: 1.02rem; font-weight: 750; line-height: 1.1; }
.tpx-stat b small { font-size: .68rem; font-weight: 600; color: var(--c-muted); }
.tpx-stat div > span { display: block; font-size: .66rem; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

.tpx-banner { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-radius: 12px; border: 1px solid; font-size: .78rem; flex-wrap: wrap; }
.tpx-banner > i { font-size: .9rem; }
.tpx-banner div { flex: 1; min-width: 220px; }
.tpx-banner b { display: block; font-size: .8rem; }
.tpx-banner p { margin: 2px 0 0; color: var(--c-muted); font-size: .72rem; line-height: 1.4; }
.tpx-banner--warning { background: rgba(217, 119, 6, .06); border-color: rgba(217, 119, 6, .26); color: #b45309; }
.tpx-banner--info { background: var(--c-brand-soft); border-color: rgba(37, 99, 235, .2); color: var(--c-text-2); }
.tpx-banner--info > i { color: var(--c-brand); }
.tpx-banner .tpx-btn { padding: 7px 10px; font-size: .74rem; }

.tpx-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpx-views { display: inline-flex; gap: 2px; padding: 3px; background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 10px; }
.tpx-views button { border: none; background: transparent; color: var(--c-muted); font: inherit; font-size: .75rem; font-weight: 650; padding: 6px 10px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.tpx-views button.is-active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--c-shadow-sm); }
.tpx-subjects { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex: 1; min-width: 220px; }
.tpx-subject-chip { border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text-2); border-radius: 999px; padding: 5px 9px; font: inherit; font-size: .72rem; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.tpx-subject-chip span { color: var(--c-muted); font-size: .64rem; }
.tpx-subject-chip.is-active { border-color: var(--subj, var(--c-brand)); color: var(--subj, var(--c-brand)); background: color-mix(in srgb, var(--subj, #2563eb) 8%, var(--c-surface)); }
.tpx-subject-chip .tpx-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--subj, var(--c-brand)); }
.tpx-search { position: relative; display: flex; align-items: center; min-width: 180px; height: 34px; }
.tpx-search i { position: absolute; left: 10px; font-size: .74rem; color: var(--c-muted); }
.tpx-search input { width: 100%; height: 34px; border: 1px solid var(--c-border); border-radius: 9px; background: var(--c-surface); color: var(--c-text); font: inherit; font-size: .78rem; padding: 0 10px 0 28px; }
.tpx-search input:focus { outline: none; border-color: var(--c-brand); box-shadow: var(--c-ring); }
.tpx-empty-toggle { border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-muted); border-radius: 9px; height: 34px; padding: 0 10px; font: inherit; font-size: .72rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.tpx-empty-toggle.is-active { color: var(--c-brand); border-color: rgba(37, 99, 235, .3); background: var(--c-brand-soft); }

.tpx-days { display: flex; flex-direction: column; gap: 10px; }
.tpx-day { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 14px; box-shadow: var(--c-shadow-sm); overflow: hidden; }
.tpx-day.is-today { border-color: rgba(37, 99, 235, .4); box-shadow: 0 0 0 1px rgba(37, 99, 235, .15), var(--c-shadow-sm); }
.tpx-day.is-empty { background: color-mix(in srgb, var(--c-surface) 85%, var(--c-surface-2)); }
.tpx-day__head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); }
.tpx-day__date { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.tpx-day__date span { font-size: .82rem; font-weight: 750; text-transform: capitalize; }
.tpx-day__date b { font-size: .74rem; color: var(--c-muted); font-weight: 600; }
.tpx-day__count { font-size: .7rem; color: var(--c-muted); }
.tpx-today { font-size: .62rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--c-brand); background: var(--c-brand-soft); padding: 2px 6px; border-radius: 999px; }
.tpx-day__head .tpx-icon-btn { margin-left: auto; }
.tpx-day__body { padding: 4px 10px 8px; }
.tpx-day__empty { display: flex; align-items: center; gap: 8px; padding: 10px 4px; color: var(--c-muted); font-size: .76rem; }
.tpx-day__empty i { opacity: .5; }
.tpx-link-btn { border: none; background: transparent; color: var(--c-brand); font: inherit; font-size: .74rem; font-weight: 650; cursor: pointer; padding: 2px 3px; }
.tpx-link-btn:hover { text-decoration: underline; }

.tpx-topic { display: flex; gap: 9px; padding: 9px 4px; border-bottom: 1px solid var(--c-border); position: relative; }
.tpx-topic:last-child { border-bottom: none; }
.tpx-topic::before { content: ''; width: 3px; border-radius: 3px; background: var(--subj); flex: 0 0 3px; }
.tpx-topic__num { width: 20px; flex: 0 0 20px; text-align: center; font-size: .7rem; font-weight: 700; color: var(--c-muted); padding-top: 2px; }
.tpx-topic__body { min-width: 0; flex: 1; }
.tpx-topic__top { display: flex; align-items: center; gap: 3px; }
.tpx-topic__top .tpx-icon-btn { opacity: .5; }
.tpx-topic:hover .tpx-topic__top .tpx-icon-btn { opacity: 1; }
.tpx-badge { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 999px; font-size: .63rem; font-weight: 750; letter-spacing: .03em; color: var(--subj, var(--c-brand)); background: color-mix(in srgb, var(--subj, #2563eb) 11%, transparent); white-space: nowrap; }
.tpx-topic h3 { margin: 4px 0 0; font-size: .86rem; font-weight: 650; line-height: 1.35; }
.tpx-topic p { margin: 3px 0 0; font-size: .74rem; line-height: 1.45; color: var(--c-muted); }
.tpx-icon-btn { width: 26px; height: 26px; border: none; background: transparent; color: var(--c-muted); border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; }
.tpx-icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.tpx-icon-btn--danger:hover { background: rgba(220, 38, 38, .1); color: var(--c-danger); }

.tpx-week-wrap { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 14px; overflow: auto; box-shadow: var(--c-shadow-sm); }
.tpx-week { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; font-size: .74rem; }
.tpx-week th { position: sticky; top: 0; z-index: 2; background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); padding: 8px 6px; text-align: center; color: var(--c-muted); font-size: .66rem; }
.tpx-week th span { display: block; text-transform: uppercase; letter-spacing: .05em; }
.tpx-week th b { display: block; font-size: .72rem; color: var(--c-text); margin-top: 1px; }
.tpx-week th.is-today { background: var(--c-brand-soft); color: var(--c-brand); }
.tpx-week__subject { position: sticky; left: 0; z-index: 3; width: 180px; min-width: 160px; background: var(--c-surface); border-right: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); padding: 8px 9px; text-align: left; }
.tpx-week th.tpx-week__subject { background: var(--c-surface-2); z-index: 4; }
.tpx-week__subject .tpx-badge { margin-bottom: 3px; }
.tpx-week__subject b { display: block; font-size: .72rem; font-weight: 600; color: var(--c-text-2); line-height: 1.3; }
.tpx-week__cell { border-right: 1px solid var(--c-border); border-bottom: 1px solid var(--c-border); vertical-align: top; padding: 5px; min-width: 120px; }
.tpx-week__cell.is-filled { background: color-mix(in srgb, var(--c-surface) 80%, var(--c-brand-soft)); }
.tpx-week__topic { display: block; width: 100%; text-align: left; border: none; background: var(--c-surface); color: var(--c-text-2); font: inherit; font-size: .7rem; line-height: 1.35; padding: 5px 6px; margin-bottom: 3px; border-radius: 6px; border-left: 2px solid var(--c-brand); cursor: pointer; }
.tpx-week__topic:hover { background: var(--c-brand-soft); color: var(--c-text); }
.tpx-week__add { width: 100%; border: 1px dashed var(--c-border); background: transparent; color: var(--c-muted); border-radius: 6px; padding: 3px; font-size: .66rem; cursor: pointer; opacity: .4; }
.tpx-week__cell:hover .tpx-week__add { opacity: 1; color: var(--c-brand); border-color: rgba(37, 99, 235, .35); }

.tpx-list-wrap { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 14px; overflow: auto; box-shadow: var(--c-shadow-sm); }
.tpx-list { width: 100%; border-collapse: collapse; min-width: 900px; font-size: .78rem; }
.tpx-list th { position: sticky; top: 0; background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); padding: 8px 10px; text-align: left; color: var(--c-muted); font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; }
.tpx-list td { padding: 8px 10px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.tpx-list tr:hover td { background: var(--c-brand-soft); }
.tpx-list__date { white-space: nowrap; font-weight: 650; }
.tpx-list__name { font-weight: 600; max-width: 320px; }
.tpx-list__desc { color: var(--c-muted); max-width: 340px; line-height: 1.4; }
.tpx-list__actions { white-space: nowrap; }

.tpx-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 46px 20px; text-align: center; color: var(--c-muted); background: var(--c-surface); border: 1px dashed var(--c-border-strong); border-radius: 14px; }
.tpx-empty i { font-size: 1.8rem; opacity: .42; }
.tpx-empty h3 { margin: 0; font-size: .98rem; color: var(--c-text); font-weight: 650; }
.tpx-empty p { margin: 0; font-size: .82rem; }

/* --------------------------------------------------------------- формы */
.tpx-form-dialog { width: min(620px, 96vw) !important; max-width: 620px !important; }
.tpx-form-dialog .cx-field textarea { resize: vertical; }
.tpx-modal-hint { margin: 10px 0 0; font-size: .76rem; line-height: 1.5; color: var(--c-muted); }

/* ------------------------------------------------------- печатный лист */
.tpx-schedule-dialog { width: min(1240px, 97vw) !important; max-width: 1240px !important; max-height: 94vh; display: flex; flex-direction: column; }
.tpx-schedule-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 14px; border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); }
.tpx-schedule-toolbar__spacer { flex: 1; }
.tpx-check { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; color: var(--c-muted); }
.tpx-check input { accent-color: var(--c-brand); }
.tpx-schedule-body { flex: 1; overflow: auto; background: #e8edf4; padding: 16px; }
.tpx-sheet-preview { background: #fff; max-width: 1050px; margin: 0 auto; box-shadow: 0 10px 40px -20px rgba(15, 23, 42, .45); border-radius: 2px; overflow: hidden; }

/* Стили внутри предпросмотра (дублируют печатный лист) */
.tpx-sheet { padding: 20px 24px; color: #111827; font-family: 'Segoe UI', Arial, sans-serif; }
.tpx-sheet__head { text-align: center; border-bottom: 2px solid #1e293b; padding-bottom: 12px; margin-bottom: 14px; }
.tpx-sheet__brand { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #64748b; margin-bottom: 4px; }
.tpx-sheet__head h1 { margin: 0; font-size: 22px; letter-spacing: .04em; }
.tpx-sheet__meta { margin-top: 5px; font-size: 11px; color: #475569; }
.tpx-sheet__foot { display: flex; justify-content: space-between; margin-top: 16px; padding-top: 8px; border-top: 1px solid #cbd5e1; font-size: 9px; color: #64748b; }
.tpx-sheet-days .sheet-day { margin-bottom: 14px; break-inside: avoid; }
.tpx-sheet-days .sheet-day > header { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #eef3fb; border-left: 4px solid #2563eb; }
.tpx-sheet-days .sheet-day__num { width: 18px; height: 18px; border-radius: 50%; background: #2563eb; color: #fff; font-size: 9px; display: inline-flex; align-items: center; justify-content: center; }
.tpx-sheet-days .sheet-day > header b { font-size: 12px; text-transform: capitalize; }
.tpx-sheet-days .sheet-day > header span { font-size: 10px; color: #64748b; margin-left: 6px; }
.tpx-sheet-days .sheet-day > header small { margin-left: auto; font-size: 9px; color: #64748b; }
.tpx-sheet-days table, .tpx-sheet-week table { width: 100%; border-collapse: collapse; font-size: 9.5px; }
.tpx-sheet-days th, .tpx-sheet-days td, .tpx-sheet-week th, .tpx-sheet-week td { border: 1px solid #cbd5e1; padding: 5px 6px; vertical-align: top; text-align: left; }
.tpx-sheet-days th, .tpx-sheet-week th { background: #f1f5f9; font-size: 8.5px; text-transform: uppercase; letter-spacing: .04em; color: #475569; }
.tpx-sheet-days td.num { width: 24px; text-align: center; color: #64748b; }
.tpx-sheet-days td.subject { width: 64px; font-weight: 700; color: var(--subj); }
.tpx-sheet-days td.desc { color: #475569; line-height: 1.35; }
.tpx-sheet-week table { table-layout: fixed; }
.tpx-sheet-week th.subject, .tpx-sheet-week td.subject { width: 150px; }
.tpx-sheet-week th { text-align: center; }
.tpx-sheet-week th span { display: block; font-size: 9px; }
.tpx-sheet-week th b { display: block; font-size: 9px; color: #111827; }
.tpx-sheet-week td.subject { background: #f8fafc; border-left: 4px solid var(--subj); }
.tpx-sheet-week td.subject b { font-size: 9px; }
.tpx-sheet-week td { vertical-align: top; }
.cell-topic { margin-bottom: 5px; }
.cell-topic b { display: block; font-size: 8.8px; font-weight: 600; }
.cell-topic small { display: block; color: #64748b; font-size: 7.8px; line-height: 1.3; margin-top: 2px; }

@media (max-width: 1200px) {
  .tpx-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 300px; }
}
@media (max-width: 900px) {
  .tpx-head__actions { width: 100%; }
  .tpx-head__actions .tpx-btn { flex: 1 1 auto; }
  .tpx-command { align-items: flex-start; }
  .tpx-select { width: 100%; }
  .tpx-stats { min-width: 0; width: 100%; }
  .tpx-toolbar { align-items: stretch; }
  .tpx-search { flex: 1 1 100%; }
  .tpx-subjects { order: 3; flex-basis: 100%; }
  .tpx-empty-toggle { margin-left: auto; }
  .tpx-schedule-toolbar .tpx-btn { flex: 1 1 auto; }
  .tpx-sheet { padding: 12px; }
}
@media (max-width: 560px) {
  .tpx-stats { grid-template-columns: 1fr 1fr; }
  .tpx-head__title h2 { font-size: 1.2rem; }
  .tpx-day__head { flex-wrap: wrap; }
  .tpx-day__count { width: 100%; }
  .tpx-view-tabs { font-size: .7rem; }
}

/* Сворачивание дней недели */
.tpx-day__head .tpx-icon-btn { margin-left: 0; }
.tpx-day__head .tpx-day__collapse { margin-left: auto; }
.tpx-day.is-collapsed .tpx-day__body { display: none; }
.tpx-day.is-collapsed .tpx-day__head { border-bottom: none; }
.tpx-day.is-collapsed .tpx-day__collapse i { color: var(--c-brand); }
