/* ========================================
   ХАЙД-ТРЕКЕР: стили UI
   ======================================== */

/* Панель статуса хайда (справа от конвертера) */
.hayd-panel {
    background: var(--white, #fff);
    border-radius: var(--radius-lg, 16px);
    border: 1px solid var(--border-gray, #e5e7eb);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.hayd-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--light-gray, #f3f4f6);
}

.hayd-panel-title {
    font-family: var(--font-arabic, 'Amiri', serif);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--dark-gray, #1f2937);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hayd-premium-badge {
    font-size: 0.75rem;
    background: linear-gradient(135deg, #D97706, #F59E0B);
    color: #fff;
    padding: 2px 8px;
    border-radius: var(--radius-full, 9999px);
    font-weight: 600;
}

/* Статус-карточка */
.hayd-status-card {
    padding: 12px;
    border-radius: var(--radius-md, 12px);
    margin-bottom: 12px;
}

.hayd-status-card.state-clean {
    background: var(--cal-tuhr-bg, #D1FAE5);
    border: 1px solid var(--cal-tuhr, #10B981);
}

.hayd-status-card.state-bleeding {
    background: var(--cal-hayd-bg, #FEE2E2);
    border: 1px solid var(--cal-hayd, #DC2626);
}

.hayd-status-card.state-nifas {
    background: var(--cal-nifas-bg, #FFEDD5);
    border: 1px solid var(--cal-nifas, #F97316);
}

.hayd-status-card.state-istihada {
    background: #FEF3C7;
    border: 1px solid #D97706;
}

.hayd-status-card.state-watching {
    background: #FEF9C3;
    border: 1px solid #CA8A04;
}

.hayd-status-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.hayd-status-card.state-clean .hayd-status-label { color: var(--emerald-dark, #065F46); }
.hayd-status-card.state-bleeding .hayd-status-label { color: #991B1B; }
.hayd-status-card.state-nifas .hayd-status-label { color: #9A3412; }
.hayd-status-card.state-istihada .hayd-status-label { color: #92400E; }
.hayd-status-card.state-watching .hayd-status-label { color: #854D0E; }

.hayd-status-text {
    font-size: 0.8125rem;
    color: var(--dark-gray, #374151);
    line-height: 1.5;
}

/* Информация об адате */
.hayd-adat-info {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.hayd-adat-item {
    flex: 1;
    background: var(--light-gray, #f9fafb);
    border-radius: var(--radius-sm, 8px);
    padding: 8px 10px;
    text-align: center;
}

.hayd-adat-item-label {
    font-size: 0.625rem;
    color: var(--medium-gray, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.hayd-adat-item-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark-gray, #1f2937);
}

/* Кнопки действий */
.hayd-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.hayd-btn {
    flex: 1;
    padding: 10px 12px;
    border-radius: var(--radius-md, 12px);
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.hayd-btn-blood-start {
    background: var(--cal-hayd, #DC2626);
    color: #fff;
}

.hayd-btn-blood-start:hover {
    background: #B91C1C;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.hayd-btn-blood-stop {
    background: var(--cal-tuhr, #10B981);
    color: #fff;
}

.hayd-btn-blood-stop:hover {
    background: var(--emerald-dark, #059669);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.hayd-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* Сообщение-руководство */
.hayd-message {
    border-radius: var(--radius-md, 12px);
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: 0.8125rem;
    line-height: 1.6;
    display: none;
}

.hayd-message.visible {
    display: block;
}

.hayd-message.severity-info {
    background: #EFF6FF;
    border: 1px solid #93C5FD;
    color: #1E40AF;
}

.hayd-message.severity-warning {
    background: #FEF9C3;
    border: 1px solid #FCD34D;
    color: #854D0E;
}

.hayd-message.severity-success {
    background: #ECFDF5;
    border: 1px solid #A7F3D0;
    color: #065F46;
}

.hayd-message.severity-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #991B1B;
}

.hayd-message-title {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.875rem;
}

.hayd-message-body {
    white-space: pre-line;
}

/* Переключатель режима */
.hayd-mode-switch {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.hayd-mode-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--border-gray, #e5e7eb);
    background: var(--white, #fff);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.6875rem;
    color: var(--medium-gray, #6b7280);
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s ease);
    text-align: center;
}

.hayd-mode-btn:hover {
    background: var(--light-gray, #f3f4f6);
}

.hayd-mode-btn.active {
    background: var(--emerald-50, #ECFDF5);
    border-color: var(--emerald, #059669);
    color: var(--emerald-dark, #065F46);
    font-weight: 600;
}

/* История циклов */
.hayd-history {
    max-height: 200px;
    overflow-y: auto;
}

.hayd-history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--light-gray, #f3f4f6);
    font-size: 0.75rem;
}

.hayd-history-item:last-child {
    border-bottom: none;
}

.hayd-history-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full, 9999px);
    flex-shrink: 0;
}

.hayd-history-dot.hayd { background: var(--cal-hayd, #DC2626); }
.hayd-history-dot.istihada { background: #D97706; }
.hayd-history-dot.nifas { background: var(--cal-nifas, #F97316); }

.hayd-history-dates {
    flex: 1;
    color: var(--dark-gray, #374151);
}

.hayd-history-duration {
    color: var(--medium-gray, #6b7280);
    font-weight: 500;
}

/* Дисклеймер */
.hayd-disclaimer {
    font-size: 0.6875rem;
    color: var(--medium-gray, #9ca3af);
    line-height: 1.5;
    padding: 8px 10px;
    background: var(--light-gray, #f9fafb);
    border-radius: var(--radius-sm, 8px);
    margin-top: 8px;
}

.hayd-disclaimer a {
    color: var(--emerald, #059669);
    text-decoration: none;
}

.hayd-disclaimer a:hover {
    text-decoration: underline;
}

/* Premium-заглушка */
.hayd-premium-gate {
    text-align: center;
    padding: 24px 16px;
}

.hayd-premium-gate-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.hayd-premium-gate-text {
    font-size: 0.875rem;
    color: var(--dark-gray, #374151);
    margin-bottom: 12px;
    line-height: 1.5;
}

.hayd-premium-gate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    background: linear-gradient(135deg, #D97706, #F59E0B);
    color: #fff;
    border: none;
    border-radius: var(--radius-full, 9999px);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s ease);
}

.hayd-premium-gate-btn:hover {
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
    transform: translateY(-1px);
}

/* Подсветка дней хайда/нифаса/тухра на календаре */
.cal-day.hayd-day {
    background: var(--cal-hayd-cell, rgba(220, 38, 38, 0.18)) !important;
}

.cal-day.nifas-day {
    background: var(--cal-nifas-cell, rgba(127, 29, 29, 0.22)) !important;
}

.cal-day.tuhr-day {
    background: var(--cal-tuhr-cell, rgba(147, 197, 253, 0.25)) !important;
}

.cal-day.istihada-day {
    background: var(--cal-istihada-cell, rgba(245, 158, 11, 0.18)) !important;
}

.cal-day.pregnant-day {
    background: var(--cal-pregnant-cell, rgba(16, 185, 129, 0.18)) !important;
}

/* Выкидыш — особый акцентный цвет (фиолетовый) */
.cal-day.miscarriage-day {
    background: var(--cal-miscarriage-cell, rgba(139, 92, 246, 0.28)) !important;
    box-shadow: inset 0 0 0 2px rgba(139, 92, 246, 0.5);
    border-radius: 6px;
}

/* Проекция адата: бледный цвет предполагаемого хайда/нифаса */
.cal-day.hayd-projected {
    background: var(--cal-hayd-cell-projected, rgba(220, 38, 38, 0.12)) !important;
}

.cal-day.nifas-projected {
    background: var(--cal-nifas-cell-projected, rgba(127, 29, 29, 0.12)) !important;
}

/* Мини-сетка — проекция */
.cal-mini-grid .cal-mini-day.hayd-projected {
    background: var(--cal-hayd-cell-projected, rgba(220, 38, 38, 0.12));
}

.cal-mini-grid .cal-mini-day.nifas-projected {
    background: var(--cal-nifas-cell-projected, rgba(127, 29, 29, 0.12));
}

/* Split-day: два цвета на одну ячейку (вертикальный градиент, высший приоритет) */
.cal-day.split-day,
.cal-day.split-day.hayd-day,
.cal-day.split-day.tuhr-day,
.cal-day.split-day.istihada-day,
.cal-day.split-day.nifas-day {
    background: linear-gradient(
        to bottom,
        var(--split-top, transparent) var(--split-ratio, 50%),
        var(--split-bottom, transparent) var(--split-ratio, 50%)
    ), var(--light-gray, #fafafa) !important;
    background-origin: border-box !important;
    background-clip: border-box !important;
}

.cal-day.split-day:hover {
    background: linear-gradient(
        to bottom,
        var(--split-top, transparent) var(--split-ratio, 50%),
        var(--split-bottom, transparent) var(--split-ratio, 50%)
    ), var(--white, #fff) !important;
    background-origin: border-box !important;
    background-clip: border-box !important;
}

/* Мини-сетка — подсветка хайда */
.cal-mini-grid .cal-mini-day.hayd-day {
    background: var(--cal-hayd-cell, rgba(220, 38, 38, 0.18));
}

.cal-mini-grid .cal-mini-day.nifas-day {
    background: var(--cal-nifas-cell, rgba(127, 29, 29, 0.22));
}

.cal-mini-grid .cal-mini-day.tuhr-day {
    background: var(--cal-tuhr-cell, rgba(147, 197, 253, 0.25));
}

.cal-mini-grid .cal-mini-day.pregnant-day {
    background: var(--cal-pregnant-cell, rgba(16, 185, 129, 0.18));
}

/* ========================================
   КОНТЕКСТНОЕ МЕНЮ при клике на дату
   ======================================== */

.cal-context-menu {
    position: fixed;
    z-index: 200;
    background: var(--white, #fff);
    border: 1px solid var(--border-gray, #e5e7eb);
    border-radius: var(--radius-md, 12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    padding: 6px;
    animation: ctxFadeIn 0.12s ease;
}

@keyframes ctxFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cal-ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm, 8px);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--dark-gray, #374151);
    cursor: pointer;
    transition: background 0.12s ease;
    text-align: start;
}

.cal-ctx-item:hover {
    background: var(--light-gray, #f3f4f6);
}

.cal-ctx-divider {
    height: 1px;
    background: var(--border-gray, #e5e7eb);
    margin: 4px 8px;
}

.cal-ctx-icon-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full, 9999px);
    flex-shrink: 0;
}

.cal-ctx-icon-dot.hayd {
    background: var(--cal-hayd, #DC2626);
}

/* ========================================
   ПАНЕЛЬ ХАЙД-СОБЫТИЙ (правая колонка)
   ======================================== */

.hayd-events-panel {
    background: var(--white, #fff);
    border-radius: var(--radius-lg, 16px);
    border: 1px solid var(--border-gray, #e5e7eb);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.hayd-events-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--light-gray, #f3f4f6);
}

.hayd-events-panel-title {
    font-family: var(--font-arabic, 'Amiri', serif);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--dark-gray, #1f2937);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hayd-events-list {
    min-height: 40px;
}

.hayd-events-empty {
    text-align: center;
    padding: 16px 8px;
    color: var(--medium-gray, #9ca3af);
    font-size: 0.8125rem;
}

.hayd-event-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full, 9999px);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.hayd-event-status-badge.state-clean {
    background: var(--cal-tuhr-bg, #D1FAE5);
    color: var(--emerald-dark, #065F46);
}

.hayd-event-status-badge.state-bleeding {
    background: var(--cal-hayd-bg, #FEE2E2);
    color: #991B1B;
}

.hayd-event-status-badge.state-nifas {
    background: var(--cal-nifas-bg, #FFEDD5);
    color: #9A3412;
}

.hayd-event-status-badge.state-watching {
    background: #FEF9C3;
    color: #854D0E;
}

.hayd-event-status-badge.state-istihada {
    background: #FEF3C7;
    color: #92400E;
}

/* Бар с датой и «+» в панели хайд-событий */
.hayd-events-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0 8px;
    border-bottom: 1px solid var(--border-gray, #e5e7eb);
    margin-bottom: 6px;
}

.hayd-events-day-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dark-gray, #374151);
}

.hayd-events-add-btn {
    width: 24px;
    height: 24px;
    border: 1.5px solid var(--emerald, #059669);
    border-radius: 6px;
    background: transparent;
    color: var(--emerald, #059669);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.12s ease;
}

.hayd-events-add-btn:hover {
    background: var(--emerald, #059669);
    color: #fff;
    transform: scale(1.1);
}

.hayd-event-record {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--light-gray, #f3f4f6);
    font-size: 0.8125rem;
}

.hayd-event-record:last-child {
    border-bottom: none;
}

.hayd-event-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full, 9999px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
}

.hayd-event-icon.blood-start {
    background: var(--cal-hayd-bg, #FEE2E2);
    color: var(--cal-hayd, #DC2626);
}

.hayd-event-icon.blood-stop {
    background: var(--cal-tuhr-bg, #D1FAE5);
    color: var(--cal-tuhr, #10B981);
}

.hayd-event-details {
    flex: 1;
}

.hayd-event-date {
    font-weight: 600;
    color: var(--dark-gray, #374151);
    margin-bottom: 2px;
}

.hayd-event-state {
    font-size: 0.75rem;
    color: var(--medium-gray, #6b7280);
}

/* Хиджри-даты в событиях */
.hayd-event-hijri {
    font-family: var(--font-arabic, 'Amiri', serif);
    font-size: 0.8rem;
    color: var(--emerald-dark, #047857);
    margin: 1px 0 2px;
    line-height: 1.4;
}

.hayd-event-hijri-inline {
    font-family: var(--font-arabic, 'Amiri', serif);
    font-size: 0.75rem;
    color: var(--emerald-dark, #047857);
    margin-inline-start: 6px;
    opacity: 0.85;
}

/* Контекстное сообщение дня */
.hayd-day-context {
    border-radius: var(--radius-md, 12px) !important;
    padding: 12px !important;
    margin-bottom: 8px;
    border: none !important;
}

.hayd-day-context.severity-bg-error {
    background: var(--cal-hayd-bg, #FEE2E2);
}

.hayd-day-context.severity-bg-warning {
    background: #FEF9C3;
}

.hayd-day-context.severity-bg-success {
    background: var(--cal-tuhr-bg, #D1FAE5);
}

.hayd-day-context.severity-bg-info {
    background: #EFF6FF;
}

/* Жёлтый блок-уведомление (ретро-сообщение, статус) */
.hayd-message-block {
    background: #FEF9C3 !important;
    border-inline-start: 3px solid #F59E0B;
    border-radius: var(--radius-sm, 6px);
    margin-bottom: 6px;
}

.hayd-message-block.severity-bg-info {
    background: #DBEAFE !important;
    border-left-color: #3B82F6;
}

.hayd-message-block.severity-bg-danger {
    background: #FEE2E2 !important;
    border-left-color: #EF4444;
}

.hayd-message-block.severity-bg-success {
    background: #D1FAE5 !important;
    border-left-color: #10B981;
}

.hayd-day-context .hayd-event-date {
    font-size: 0.8125rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.hayd-day-context .hayd-event-state {
    font-size: 0.75rem;
    line-height: 1.5;
}

/* Контейнер таймлайна (оборачивает 2+ суб-событий) */
.hayd-timeline {
    position: relative;
    padding-inline-start: 32px;
}

/* Под-события цикла (individual events) */
.hayd-event-record.hayd-event-sub {
    padding: 6px 0 6px 32px;
    border-bottom: none;
    font-size: 0.75rem;
    position: relative;
}

/* Внутри таймлайна — отступ даёт контейнер */
.hayd-timeline .hayd-event-record.hayd-event-sub {
    padding-inline-start: 0;
}

/* Линия только внутри таймлайна (2+ событий) */
.hayd-event-record.hayd-event-sub::before {
    display: none;
}

.hayd-timeline .hayd-event-record.hayd-event-sub::before {
    display: block;
    content: '';
    position: absolute;
    left: 3px; /* центр 8px иконки = 4px, минус пол-ширины линии */
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: var(--border-gray, #e5e7eb);
}

/* Первый — линия начинается от центра точки */
.hayd-timeline .hayd-event-record.hayd-event-sub:first-child::before {
    top: 14px; /* 6px padding-top + 4px margin-top + 4px half-icon */
}

/* Последний — линия заканчивается у центра точки */
.hayd-timeline .hayd-event-record.hayd-event-sub:last-child::before {
    bottom: 14px;
}

.hayd-event-sub-icon {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full, 9999px);
    flex-shrink: 0;
    margin-top: 4px;
    position: relative;
    z-index: 1;
}

.hayd-event-sub-icon.sub-blood {
    background: var(--cal-hayd, #DC2626);
}

.hayd-event-sub-icon.sub-clean {
    background: var(--cal-tuhr, #10B981);
}

.hayd-event-record.hayd-event-sub.highlight-today {
    background: var(--light-gray, #f9fafb);
    border-radius: var(--radius-sm, 8px);
}

.hayd-event-record.hayd-cycle-header {
    border-bottom: none;
    padding-bottom: 2px;
}

/* Кнопка редактирования события */
.hayd-event-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    padding: 4px 6px;
    border-radius: var(--radius-sm, 8px);
    opacity: 0.4;
    transition: opacity 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
}

.hayd-event-edit-btn:hover {
    opacity: 1;
    background: var(--light-gray, #f3f4f6);
}

/* Кнопка удаления события */
.hayd-event-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    padding: 4px 6px;
    border-radius: var(--radius-sm, 8px);
    opacity: 0.3;
    transition: opacity 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
}

.hayd-event-delete-btn:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
}

/* Сворачиваемое сообщение-руководство */
.hayd-guidance {
    margin-top: 12px;
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
}

.hayd-guidance-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-gray, #e5e7eb);
    background: var(--light-gray, #f9fafb);
    border-radius: var(--radius-md, 12px);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dark-gray, #374151);
    cursor: pointer;
    transition: background 0.12s ease;
}

.hayd-guidance-toggle:hover {
    background: var(--border-gray, #e5e7eb);
}

.hayd-guidance-arrow {
    transition: transform 0.2s ease;
    font-size: 0.625rem;
}

.hayd-guidance.expanded .hayd-guidance-arrow {
    transform: rotate(90deg);
}

.hayd-guidance-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.hayd-guidance.expanded .hayd-guidance-body {
    max-height: 300px;
}

.hayd-guidance-content {
    padding: 10px 12px;
    font-size: 0.8125rem;
    line-height: 1.6;
    border: 1px solid var(--border-gray, #e5e7eb);
    border-top: none;
    border-radius: 0 0 var(--radius-md, 12px) var(--radius-md, 12px);
}

.hayd-guidance-content.severity-info { background: #EFF6FF; color: #1E40AF; }
.hayd-guidance-content.severity-warning { background: #FEF9C3; color: #854D0E; }
.hayd-guidance-content.severity-success { background: #ECFDF5; color: #065F46; }
.hayd-guidance-content.severity-error { background: #FEF2F2; color: #991B1B; }

/* Ряд переключателей (исторический + хайд) */
.cal-toggles-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

/* Кнопка отмены в контекстном меню */
.cal-ctx-undo {
    color: var(--medium-gray, #6b7280) !important;
    font-size: 0.75rem !important;
}

.cal-ctx-undo:hover {
    color: var(--danger, #DC2626) !important;
}

/* ========================================
   МОДАЛКА ВЫБОРА ВРЕМЕНИ
   ======================================== */

.hayd-time-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ctxFadeIn 0.15s ease;
}

.hayd-time-modal {
    background: var(--white, #fff);
    border-radius: var(--radius-lg, 16px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    width: 320px;
    max-width: 90vw;
    overflow: hidden;
}

.hayd-time-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--light-gray, #f3f4f6);
}

.hayd-time-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark-gray, #1f2937);
    margin: 0;
}

.hayd-time-modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--medium-gray, #9ca3af);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.hayd-time-modal-close:hover {
    color: var(--dark-gray, #1f2937);
}

.hayd-time-modal-body {
    padding: 16px;
}

.hayd-time-modal-date {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark-gray, #374151);
    margin-bottom: 12px;
    text-align: center;
}

.hayd-time-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 8px;
}

.hayd-time-label {
    font-size: 0.8125rem;
    color: var(--dark-gray, #374151);
    font-weight: 500;
}

.hayd-time-input {
    padding: 8px 12px;
    border: 1px solid var(--border-gray, #e5e7eb);
    border-radius: var(--radius-sm, 8px);
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark-gray, #1f2937);
    text-align: center;
    width: 120px;
}

.hayd-time-input:focus {
    outline: none;
    border-color: var(--emerald, #059669);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 15%, transparent);
}

.hayd-time-hint {
    font-size: 0.6875rem;
    color: var(--medium-gray, #9ca3af);
    text-align: center;
    line-height: 1.4;
}

.hayd-time-modal-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--light-gray, #f3f4f6);
    justify-content: flex-end;
}

.hayd-time-btn-cancel {
    padding: 8px 16px;
    border: 1px solid var(--border-gray, #e5e7eb);
    background: var(--white, #fff);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.8125rem;
    color: var(--medium-gray, #6b7280);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.12s ease;
}

.hayd-time-btn-cancel:hover {
    background: var(--light-gray, #f3f4f6);
}

.hayd-time-btn-confirm {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-sm, 8px);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s ease;
}

.hayd-time-btn-confirm.blood-start {
    background: var(--cal-hayd, #DC2626);
    color: #fff;
}

.hayd-time-btn-confirm.blood-start:hover {
    background: #B91C1C;
}

.hayd-time-btn-confirm.blood-stop {
    background: var(--cal-tuhr, #10B981);
    color: #fff;
}

.hayd-time-btn-confirm.blood-stop:hover {
    background: var(--emerald-dark, #059669);
}

/* ========================================
   ONBOARDING: выбор мубтадиа / мутада
   ======================================== */

.hayd-onboarding-modal {
    max-width: 420px;
}

.hayd-onboarding-desc {
    font-size: 0.8125rem;
    color: var(--medium-gray, #6b7280);
    margin: 0 0 16px;
    line-height: 1.5;
}

.hayd-onboarding-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.hayd-onboarding-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 2px solid var(--border-gray, #e5e7eb);
    border-radius: var(--radius-md, 12px);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.hayd-onboarding-option:hover {
    border-color: var(--emerald, #10B981);
    background: rgba(16, 185, 129, 0.04);
}

.hayd-onboarding-option:has(input:checked) {
    border-color: var(--emerald, #10B981);
    background: rgba(16, 185, 129, 0.08);
}

.hayd-onboarding-option input[type="radio"] {
    margin-top: 3px;
    accent-color: var(--emerald, #10B981);
}

.hayd-onboarding-option-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hayd-onboarding-option-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dark-gray, #1f2937);
}

.hayd-onboarding-option-hint {
    font-size: 0.75rem;
    color: var(--medium-gray, #6b7280);
    line-height: 1.4;
}

.hayd-onboarding-adat {
    padding: 12px 14px;
    background: var(--light-gray, #f9fafb);
    border-radius: var(--radius-md, 12px);
    margin-bottom: 8px;
}

.hayd-onboarding-adat-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--dark-gray, #374151);
    margin-bottom: 8px;
}

.hayd-onboarding-adat-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.hayd-onboarding-adat-unit {
    font-size: 0.8125rem;
    color: var(--medium-gray, #6b7280);
    margin-inline-end: 8px;
}

.hayd-onboarding-adat-hint {
    font-size: 0.7rem;
    color: var(--medium-gray, #9ca3af);
    margin-top: 8px;
}

/* ========================================
   ЛЕГЕНДА ЦВЕТОВ (Памятка)
   ======================================== */

.hayd-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 10px 14px;
    background: var(--light-gray, #f9fafb);
    border: 1px solid var(--border-gray, #e5e7eb);
    border-radius: var(--radius-md, 12px);
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--dark-gray, #374151);
}

.hayd-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hayd-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.hayd-legend-dot.legend-hayd {
    background: var(--cal-hayd-cell, rgba(220, 38, 38, 0.35));
    border: 1px solid rgba(220, 38, 38, 0.5);
}

.hayd-legend-dot.legend-tuhr {
    background: var(--cal-tuhr-cell, rgba(147, 197, 253, 0.4));
    border: 1px solid rgba(147, 197, 253, 0.6);
}

.hayd-legend-dot.legend-nifas {
    background: var(--cal-nifas-cell, rgba(127, 29, 29, 0.35));
    border: 1px solid rgba(127, 29, 29, 0.5);
}

.hayd-legend-dot.legend-istihada {
    background: var(--cal-istihada-cell, rgba(245, 158, 11, 0.35));
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.hayd-legend-dot.legend-pregnant {
    background: var(--cal-pregnant-cell, rgba(16, 185, 129, 0.35));
    border: 1px solid rgba(16, 185, 129, 0.5);
}

.hayd-legend-dot.legend-miscarriage {
    background: var(--cal-miscarriage-cell, rgba(139, 92, 246, 0.4));
    border: 2px solid rgba(139, 92, 246, 0.6);
}

.hayd-legend-dot.legend-split {
    background: linear-gradient(to bottom, rgba(220,38,38,0.3) 50%, rgba(147,197,253,0.35) 50%);
    border: 1px solid rgba(150,150,150,0.4);
}

.hayd-legend-dot.legend-projected {
    background: var(--cal-hayd-cell-projected, rgba(220, 38, 38, 0.12));
    border: 1px dashed rgba(220, 38, 38, 0.4);
}

/* Адаптив */
@media (max-width: 768px) {
    .hayd-panel {
        margin-top: 12px;
    }

    .hayd-adat-info {
        flex-direction: column;
        gap: 6px;
    }

    .hayd-mode-switch {
        flex-wrap: wrap;
    }
}
