/* --- ПАНЕЛЬ КОЛЕГ --- */
.profiles-overlay {
    z-index: var(--z-overlay-profiles);
}

.profiles-card {
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* --- Список профілів --- */
.profiles-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.profiles-list:empty {
    display: none;
}

.profile-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--surface-block-padding-sm);
    border-radius: var(--surface-block-radius-sm);
    background: var(--surface-panel-subtle);
    border: 1px solid var(--card-border);
    transition: var(--control-transition);
}

.profile-item.dimmed {
    opacity: 0.45;
}

.profile-item-color {
    width: 14px;
    height: 14px;
    border-radius: var(--marker-cube-radius);
    flex-shrink: 0;
    border: 2px solid var(--card-border);
}

.profile-item-info {
    flex: 1;
    min-width: 0;
}

.profile-item-name {
    font-size: var(--type-body-md-size);
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-item-schedule {
    font-size: var(--type-body-xs-size);
    color: var(--text-secondary);
    margin-top: 0;
}

.profile-item-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

.profile-action-btn {
    width: var(--icon-button-size);
    height: var(--icon-button-size);
    border-radius: var(--icon-button-radius);
    border: 1px solid var(--surface-panel-muted-border);
    background: var(--surface-control);
    cursor: pointer;
    font-size: var(--icon-size-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--control-transition);
    padding: 0;
    color: var(--text-primary);
    box-shadow: var(--surface-panel-elevated-shadow);
}

.profile-action-btn:hover {
    background: var(--surface-control-hover);
    box-shadow: var(--surface-panel-elevated-shadow-hover);
    transform: var(--icon-hover-transform);
}

.profile-action-btn.danger:hover {
    background: var(--danger-soft);
    border-color: var(--danger-soft-border);
}

.profile-action-btn .icon-glyph {
    width: 1em;
    height: 1em;
}

/* --- Форма додавання --- */
.profiles-add-form {
    border-top: 1px solid var(--card-border);
    padding-top: var(--space-3);
}

.profiles-add-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--button-compact-radius);
    border: 1px solid var(--card-border);
    background: var(--surface-panel-subtle);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--control-transition);
    box-shadow: none;
}

.profiles-add-toggle:hover {
    background: var(--surface-control);
    border-color: var(--surface-panel-muted-border);
}

.profiles-add-heading {
    font-size: var(--type-title-card-size);
    font-weight: 800;
    line-height: var(--type-title-card-line);
    margin: 0;
    color: var(--text-primary);
}

.profiles-add-toggle-icon {
    width: var(--icon-button-size-compact);
    height: var(--icon-button-size-compact);
    flex: 0 0 var(--icon-button-size-compact);
    border-radius: var(--disclosure-button-radius);
    border: 1px solid var(--surface-panel-muted-border);
    background: var(--surface-control);
    color: var(--accent);
    box-shadow: var(--surface-panel-elevated-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--icon-size-sm);
    line-height: 1;
    transition: var(--control-transition);
}

.profiles-add-toggle-icon .icon-glyph {
    width: 1em;
    height: 1em;
}

.profiles-add-toggle:hover .profiles-add-toggle-icon {
    background: var(--surface-control-hover);
    box-shadow: var(--surface-panel-elevated-shadow-hover);
}

.profiles-add-form.is-expanded .profiles-add-toggle-icon {
    transform: rotate(90deg);
}

.profiles-add-collapse {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transform: translateY(var(--expand-reveal-offset));
    pointer-events: none;
    transition: max-height var(--expand-reveal-size-duration) var(--expand-reveal-easing), opacity var(--expand-reveal-fade-duration) var(--expand-reveal-easing), transform var(--expand-reveal-fade-duration) var(--expand-reveal-easing), margin-top var(--expand-reveal-fade-duration) var(--expand-reveal-easing);
}

.profiles-add-form.is-expanded .profiles-add-collapse {
    max-height: 960px;
    opacity: 1;
    margin-top: var(--space-3);
    transform: translateY(0);
    pointer-events: auto;
}

.profiles-add-collapse .custom-input-group {
    margin-bottom: 0;
}

.profiles-schedule-row {
    margin-bottom: 0;
}

.profiles-schedule-templates {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
}

.schedule-btn-sm {
    min-height: 58px;
    padding: var(--space-2);
    border-radius: var(--button-compact-radius);
    font-size: var(--type-label-sm-size);
    gap: var(--space-1);
}

.schedule-btn-sm strong {
    font-size: var(--type-number-xs-size);
    line-height: var(--type-number-xs-line);
}

.profile-schedule-caption {
    font-size: var(--type-caption-xxs-size);
    line-height: var(--type-caption-xxs-line);
    opacity: 0.82;
    text-wrap: balance;
}

.profiles-custom-fields {
    display: flex;
    gap: var(--space-3);
    margin-bottom: 0;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(var(--expand-reveal-offset));
    pointer-events: none;
    transition: max-height var(--expand-reveal-size-duration) var(--expand-reveal-easing), opacity var(--expand-reveal-fade-duration) var(--expand-reveal-easing), transform var(--expand-reveal-fade-duration) var(--expand-reveal-easing), margin-bottom var(--expand-reveal-fade-duration) var(--expand-reveal-easing);
}

.profiles-custom-fields[hidden] {
    display: none;
}

.profiles-custom-fields.is-open {
    max-height: 160px;
    opacity: 1;
    transform: translateY(0);
    margin-bottom: var(--space-1);
    pointer-events: auto;
}

.profiles-custom-fields .custom-input-group {
    flex: 1;
}

.profiles-meta-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(104px, 120px);
    gap: var(--space-3);
    align-items: end;
}

.profiles-meta-row > .custom-input-group {
    margin-bottom: 0;
}

.profile-color-group {
    min-width: 0;
}

.profile-color-picker {
    position: relative;
    width: 100%;
    min-height: var(--field-min-height);
}

.profile-color-input {
    position: absolute;
    width: 1px;
    height: 1px;
    inset: auto;
    opacity: 0;
    pointer-events: none;
}

.profile-color-trigger {
    width: 100%;
    min-height: var(--field-min-height);
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--field-padding);
    border: 1px solid color-mix(in srgb, var(--card-border-strong) 86%, transparent);
    border-radius: var(--button-compact-radius);
    background: color-mix(in srgb, var(--surface-panel-subtle) 72%, var(--surface-input));
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: var(--control-transition);
    box-sizing: border-box;
    box-shadow: none;
}

.profile-color-trigger:hover {
    background: color-mix(in srgb, var(--surface-panel-subtle) 82%, var(--surface-input));
    border-color: color-mix(in srgb, var(--accent) 24%, var(--card-border-strong));
}

.profile-color-trigger-copy {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.profile-color-trigger-title {
    font-size: var(--type-label-sm-size);
    font-weight: 700;
    line-height: var(--type-label-sm-line);
}

.profile-color-trigger-help {
    font-size: var(--type-body-xs-size);
    line-height: var(--type-body-xs-line);
}

.profile-color-preview {
    width: 46px;
    min-width: 46px;
    min-height: 28px;
    border-radius: calc(var(--button-compact-radius) - 4px);
    border: 1px solid color-mix(in srgb, var(--card-border-strong) 86%, transparent);
    background: var(--surface-control);
    box-shadow: none;
}

.profile-color-picker-compact .profile-color-trigger {
    height: var(--field-min-height);
    min-height: var(--field-min-height);
    justify-content: center;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--card-border-strong) 86%, transparent);
    border-radius: var(--field-radius);
    background: var(--surface-input);
    box-shadow: none;
    overflow: hidden;
}

.profile-color-picker-compact .profile-color-trigger-copy {
    display: none;
}

.profile-color-picker-compact .profile-color-preview {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.profile-color-picker:focus-within .profile-color-trigger {
    border-color: color-mix(in srgb, var(--accent) 44%, var(--card-border-strong));
    box-shadow: var(--focus-ring-soft);
}

.profile-color-picker-compact:focus-within .profile-color-trigger {
    border-color: var(--accent);
    box-shadow: var(--focus-ring-soft);
}

.profile-color-picker-compact:focus-within .profile-color-preview {
    border-color: color-mix(in srgb, var(--card-border-strong) 86%, transparent);
    box-shadow: none;
}

.profile-color-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay-color-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
    background: var(--modal-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--overlay-fade-duration) var(--motion-ease-exit);
}

.profile-color-modal.active {
    opacity: 1;
    pointer-events: auto;
}

.profile-color-modal-card {
    width: 100%;
    max-width: 360px;
    padding: var(--space-5);
    border-radius: var(--shell-radius);
    background: var(--main-container-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    transform: var(--modal-card-initial-transform);
    opacity: 0;
    transition: var(--modal-card-transition);
}

.profile-color-modal.active .profile-color-modal-card {
    transform: var(--modal-card-active-transform);
    opacity: 1;
}

.profile-color-modal-header {
    gap: var(--space-3);
}

.profile-color-swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-2);
}

.profile-color-swatch {
    min-height: var(--field-min-height);
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--button-compact-radius);
    border: 1px solid var(--card-border);
    background: var(--surface-control);
    cursor: pointer;
    transition: var(--control-transition);
}

.profile-color-swatch:hover {
    background: var(--surface-control-hover);
    border-color: var(--surface-panel-muted-border);
}

.profile-color-swatch.is-selected {
    border-color: var(--interactive-active-border);
    box-shadow: var(--interactive-active-inset), var(--interactive-active-shadow);
}

.profile-color-swatch-chip {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--disclosure-button-radius);
    border: 1px solid var(--card-border);
}

.profile-color-modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
}

.profile-color-modal-actions .schedule-btn-action {
    min-height: var(--icon-button-size);
    padding: var(--space-3) var(--space-2);
}

/* --- Точки на клітинках календаря --- */
.profile-dots {
    display: flex;
    gap: var(--marker-cube-gap);
    position: absolute;
    bottom: var(--space-1);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-dots);
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    max-width: calc(100% - var(--space-2));
    padding-inline: var(--space-1);
    overflow: hidden;
}

.profile-dot {
    width: var(--marker-cube-size);
    height: var(--marker-cube-size);
    border-radius: var(--marker-cube-radius);
    flex-shrink: 0;
    box-shadow: var(--marker-cube-ring);
}

.profile-dot-more {
    width: var(--marker-cube-size);
    min-width: var(--marker-cube-size);
    height: var(--marker-cube-size);
    border-radius: var(--marker-cube-radius);
    font-size: var(--marker-cube-font-size);
    font-weight: 800;
    padding: 0;
    background: var(--dot-overflow-bg);
    color: var(--text-on-accent);
    line-height: var(--marker-cube-size);
    text-align: center;
    box-shadow: var(--marker-cube-ring);
}

/* --- Профілі у модалці дня --- */
.modal-profiles {
    width: 100%;
    margin-top: var(--space-4);
    margin-bottom: var(--space-4);
    text-align: left;
}

.modal-profiles-heading {
    font-size: var(--type-label-sm-size);
    font-weight: 700;
    text-transform: uppercase;
    line-height: var(--type-label-sm-line);
    letter-spacing: var(--type-label-xs-track);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.modal-profile-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--surface-panel-muted-border);
}

.modal-profile-row:last-child {
    border-bottom: none;
}

.modal-profile-row.dimmed {
    opacity: 0.4;
}

.modal-profile-dot {
    width: var(--marker-cube-size);
    height: var(--marker-cube-size);
    border-radius: var(--marker-cube-radius);
    flex-shrink: 0;
}

.modal-profile-name {
    flex: 1;
    font-size: var(--type-body-md-size);
    font-weight: 600;
    color: var(--text-primary);
}

.modal-profile-badge {
    font-size: var(--type-label-sm-size);
    font-weight: 700;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--button-compact-radius);
    flex-shrink: 0;
}

.modal-profile-badge[data-status="work"] {
    background: var(--work-bg-start);
    color: var(--work-text);
}

.modal-profile-badge[data-status="off"] {
    background: var(--off-bg-start);
    color: var(--off-text);
}

/* --- Редагування профілю (inline) --- */
.profile-edit-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: var(--z-overlay-profile-edit);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--overlay-fade-duration) var(--motion-ease-exit);
}

.profile-edit-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.profile-edit-card {
    background: var(--main-container-bg);
    border-radius: var(--shell-radius);
    padding: var(--space-6);
    width: 100%;
    max-width: 360px;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    transform: var(--modal-card-initial-transform);
    opacity: 0;
    transition: var(--modal-card-transition);
}

.profile-edit-overlay.active .profile-edit-card {
    transform: var(--modal-card-active-transform);
    opacity: 1;
}

.profile-edit-card .custom-input-group {
    margin-bottom: 0;
}

.profile-edit-header {
    margin-bottom: 0;
}

.profile-edit-title {
    font-size: var(--type-title-section-size);
    font-weight: 800;
    line-height: var(--type-title-section-line);
    letter-spacing: var(--type-title-section-track);
    margin: 0;
    color: var(--text-primary);
}

.profile-edit-schedule-row {
    margin-bottom: 0;
}

.profile-edit-schedule-templates {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
}

.profile-edit-schedule-btn {
    min-height: 50px;
    padding: var(--space-2) var(--space-1);
    border-radius: var(--button-compact-radius);
}

.profile-edit-schedule-btn strong {
    font-size: var(--type-body-ui-size);
}

.profile-edit-schedule-label {
    font-size: var(--type-caption-xxs-size);
}

.profile-edit-date-group {
    margin-bottom: 0;
}

.profile-edit-date-group .control-input {
    min-height: var(--field-min-height);
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
}

.profile-edit-color-group {
    margin-bottom: 0;
}

.profile-edit-inline-color-picker {
    width: 100%;
    min-width: 0;
}

.profile-edit-color-input,
.profile-edit-inline-color-picker,
.profile-edit-inline-color-picker .profile-color-trigger,
.profile-edit-inline-color-picker .profile-color-preview {
    min-height: var(--field-min-height);
}

.profile-edit-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: 0;
}

.profile-edit-actions .schedule-btn-action {
    flex: 1;
}

@media (max-width: 430px) {
    .profiles-meta-row {
        grid-template-columns: minmax(0, 1fr) 104px;
    }
}
