/* === Инструмент "Норма часов" === */

.main-content:has(.norma-page) { padding-top: 0; }

.norma-page {
  display: flex;
  flex-direction: column;
}

.norma-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 0 32px;
  container-type: inline-size;
}

/* Настройки + месячные часы: 1 колонка по умолчанию,
   2 — при широком контейнере (settings слева, addHours/absence справа) */
.norma-settings-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@container (min-width: 900px) {
  .norma-settings-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
}

.norma-beta {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-on-surface-secondary);
  margin-left: 4px;
}

/* --- Статус производственного календаря --- */
.norma-status {
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  padding: 10px 16px;
  border-radius: var(--radius);
}
.norma-status--ok {
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}
.norma-status--error {
  color: #F44336;
  background: color-mix(in srgb, #F44336 12%, transparent);
}

/* --- Объединённый блок (норма/период слева + пикеры справа) под календарём --- */
.norma-range-summary {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.norma-range-summary__left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}
.norma-range-summary__right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.norma-range-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-on-surface);
}
.norma-range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.norma-range-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 130px;
  height: 36px;
  padding: 0 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-primary);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.norma-range-picker:hover {
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
}
.norma-range-picker__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-on-surface);
  pointer-events: none;
}
.norma-range-picker__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: 0;
  padding: 0;
  color-scheme: light;
}
[data-theme="dark"] .norma-range-picker__input { color-scheme: dark; }

/* --- Переключатель вида (3 мес / 6 мес / год) --- */
.norma-view-tabs {
  margin-top: 4px;
}

/* --- Шапка календаря с навигацией --- */
.norma-cal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.norma-cal-nav {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.norma-cal-nav:hover {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}
.norma-cal-title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-on-surface);
}

/* --- Общий контейнер календаря --- */
.norma-cal {
  padding: 0;
}

/* --- Сетка месяцев (3/6/12) --- */
.norma-multi {
  display: grid;
  gap: 14px;
}
.norma-multi--3 {
  grid-template-columns: repeat(3, 1fr);
}
.norma-multi--6 {
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.norma-multi--12 {
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* --- Мини-блок месяца --- */
.norma-mini {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px;
}
.norma-multi--6 .norma-mini {
  padding: 6px;
}
.norma-multi--12 .norma-mini {
  padding: 4px;
}
.norma-mini__header {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
  color: var(--color-on-surface);
  text-transform: capitalize;
}
.norma-multi--6 .norma-mini__header,
.norma-multi--12 .norma-mini__header {
  font-size: 12px;
  margin-bottom: 4px;
}

.norma-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 2px;
}
.norma-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-on-surface-secondary);
  padding: 2px 0;
}
.norma-weekday--weekend {
  color: #F44336;
}
.norma-multi--6 .norma-weekday,
.norma-multi--12 .norma-weekday {
  font-size: 10px;
}

.norma-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

/* --- Ячейка дня (портирована из Flutter dayStyledWidget) --- */
.norma-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-family);
  color: var(--color-on-surface);
  transition: transform 0.05s, background 0.15s;
}
.norma-multi--12 .norma-day {
  border-radius: 3px;
}
.norma-day--outside {
  cursor: default;
  pointer-events: none;
}
.norma-day--outside .norma-day__num {
  color: var(--color-on-surface-secondary);
  opacity: 0.25;
}
.norma-day:hover:not(.norma-day--outside) .norma-day__circle {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}
.norma-day:active:not(.norma-day--outside) {
  transform: scale(0.93);
}

.norma-day__circle {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.norma-multi--12 .norma-day__circle {
  width: 26px;
  height: 26px;
}

.norma-day__num {
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
}
.norma-multi--12 .norma-day__num {
  font-size: 12px;
}

/* Отметка "сегодня" */
.norma-day--today .norma-day__num {
  font-weight: 800;
  color: var(--color-primary);
}

/* Выделенный день — полностью выделенный контейнер с закруглёнными краями.
   В режиме "Год" (.norma-multi--12) радиус закругления в два раза меньше. */
.norma-day--selected {
  background: color-mix(in srgb, var(--color-primary) 22%, transparent);
}
.norma-day--selected .norma-day__circle {
  border-color: transparent;
  background: transparent;
}
.norma-day--selected .norma-day__num {
  color: var(--color-primary);
  font-weight: 800;
}

/* Соседние выделенные дни в одном ряду склеиваются без скруглений между ними.
   Исключаем переход с воскресенья на понедельник (границы недельных рядов). */
.norma-day--selected + .norma-day--selected:not(:nth-child(7n+1)) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.norma-day--selected:has(+ .norma-day--selected):not(:nth-child(7n)) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Выделенные дни, стоящие вертикально друг под другом (через 7 ячеек в сетке),
   склеиваются без горизонтальных скруглений между ними. */
.norma-day--selected
  + .norma-day + .norma-day + .norma-day + .norma-day + .norma-day + .norma-day
  + .norma-day--selected {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.norma-day--selected:has(
  + .norma-day + .norma-day + .norma-day + .norma-day + .norma-day + .norma-day
  + .norma-day--selected
) {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* Часы (производственный календарь) — в правом нижнем углу */
.norma-day__hours {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 10px;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.norma-day__hours--dim {
  opacity: 0.5;
}
.norma-multi--12 .norma-day__hours {
  font-size: 9px;
  bottom: 1px;
  right: 2px;
}

/* --- Блок результатов (снизу) --- */
.norma-result-bottom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
  border-radius: var(--radius);
}
.norma-result-line {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-on-surface);
}
.norma-result-line__label {
  color: var(--color-on-surface);
}
.norma-result-line b {
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}
.norma-result-note {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
  font-size: 12px;
  line-height: 1.45;
  color: var(--color-on-surface-secondary);
}

/* --- Карточка настроек (norma / weekNorma / holidays) --- */
.norma-settings-card {
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.norma-settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.norma-settings-hint {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-primary);
}

/* --- Инпут с суффиксом --- */
.norma-input-wrap {
  position: relative;
  width: 110px;
  flex-shrink: 0;
}
.norma-input {
  width: 100%;
  height: 40px;
  padding: 0 30px 0 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-primary);
  border-radius: 12px;
  font-size: 15px;
  font-family: var(--font-family);
  color: var(--color-on-surface);
  outline: none;
  box-sizing: border-box;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.norma-input:hover {
  background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
}
.norma-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 25%, transparent);
}
.norma-input__suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--color-on-surface-secondary);
  pointer-events: none;
}

/* --- Тумблер "праздники в переработку" --- */
.norma-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  font-family: var(--font-family);
  color: var(--color-on-surface);
  text-align: left;
}
.norma-toggle__track {
  position: relative;
  width: 42px;
  height: 24px;
  background: color-mix(in srgb, var(--color-on-surface-secondary) 30%, transparent);
  border-radius: 999px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.norma-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.norma-toggle--on .norma-toggle__track {
  background: #4CAF50;
}
.norma-toggle--on .norma-toggle__thumb {
  transform: translateX(18px);
}
.norma-toggle__label {
  font-size: 14px;
  line-height: 1.35;
}

/* --- Подсказка между блоками --- */
.norma-hint {
  text-align: center;
  font-size: 13px;
  color: var(--color-on-surface-secondary);
  padding: 4px 0;
}

/* --- add/absence hours за месяц --- */
.norma-month-hours {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  border-radius: var(--radius);
  padding: 16px 20px;
}

/* --- Кнопка "Очистить все дни" в toolbar (danger outline) --- */
.norma-btn-clear[hidden] {
  display: none;
}
.norma-btn-clear {
  border-color: color-mix(in srgb, #F44336 45%, transparent);
  color: color-mix(in srgb, #F44336 70%, transparent);
}
.norma-btn-clear:hover:not([disabled]):not(.btn--disabled) {
  background: color-mix(in srgb, #F44336 12%, transparent);
  border-color: #F44336;
  color: #F44336;
}

/* --- Кнопки --- */
.norma-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-primary);
}
.norma-btn--danger {
  border-color: #F44336;
  color: #F44336;
  background: var(--color-surface);
}
.norma-btn--danger:hover {
  background: color-mix(in srgb, #F44336 12%, var(--color-surface));
}
.norma-btn--ghost {
  color: var(--color-on-surface-secondary);
}
.norma-btn--ghost:hover {
  background: color-mix(in srgb, var(--color-on-surface) 8%, transparent);
}
.norma-btn--disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* --- Модалки (Отметить смены / Очистить) --- */
.norma-modal .tool-modal__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.norma-modal-intro {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-on-surface);
}
.norma-modal-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-on-surface);
}
.norma-teams-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.norma-team-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--team-color) 18%, transparent);
  border: 2px solid color-mix(in srgb, var(--team-color) 60%, transparent);
  border-radius: 50%;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 700;
  color: var(--color-on-surface);
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}
.norma-team-btn:hover {
  background: color-mix(in srgb, var(--team-color) 28%, transparent);
}
.norma-team-btn--active {
  background: var(--team-color);
  border-color: var(--team-color);
  color: #fff;
  transform: scale(1.05);
}
[data-theme="dark"] .norma-team-btn--active {
  color: #000;
}
.norma-period-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.norma-period-btn {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-primary);
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.35;
  color: var(--color-on-surface);
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.norma-period-btn:hover {
  background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
}
